1
- use clap:: { crate_version} ;
1
+ use clap:: crate_version;
2
2
3
3
use std:: env;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
6
- use clap:: { App , ArgMatches , SubCommand , AppSettings } ;
6
+ use clap:: { App , AppSettings , ArgMatches , SubCommand } ;
7
7
8
+ use mdbook:: errors:: Result as Result3 ;
8
9
use mdbook:: MDBook ;
9
- use mdbook:: errors:: { Result as Result3 } ;
10
10
11
+ use failure:: Error ;
11
12
#[ cfg( feature = "linkcheck" ) ]
12
13
use mdbook:: renderer:: RenderContext ;
13
14
#[ cfg( feature = "linkcheck" ) ]
14
15
use mdbook_linkcheck:: { self , errors:: BrokenLinks } ;
15
- use failure:: Error ;
16
16
17
17
fn main ( ) {
18
18
let d_message = "-d, --dest-dir=[dest-dir]
@@ -21,18 +21,22 @@ fn main() {
21
21
'A directory for your book{n}(Defaults to Current Directory when omitted)'" ;
22
22
23
23
let matches = App :: new ( "rustbook" )
24
- . about ( "Build a book with mdBook" )
25
- . author ( "Steve Klabnik <steve@steveklabnik.com>" )
26
- . version ( & * format ! ( "v{}" , crate_version!( ) ) )
27
- . setting ( AppSettings :: SubcommandRequired )
28
- . subcommand ( SubCommand :: with_name ( "build" )
29
- . about ( "Build the book from the markdown files" )
30
- . arg_from_usage ( d_message)
31
- . arg_from_usage ( dir_message) )
32
- . subcommand ( SubCommand :: with_name ( "linkcheck" )
33
- . about ( "Run linkcheck with mdBook 3" )
34
- . arg_from_usage ( dir_message) )
35
- . get_matches ( ) ;
24
+ . about ( "Build a book with mdBook" )
25
+ . author ( "Steve Klabnik <steve@steveklabnik.com>" )
26
+ . version ( & * format ! ( "v{}" , crate_version!( ) ) )
27
+ . setting ( AppSettings :: SubcommandRequired )
28
+ . subcommand (
29
+ SubCommand :: with_name ( "build" )
30
+ . about ( "Build the book from the markdown files" )
31
+ . arg_from_usage ( d_message)
32
+ . arg_from_usage ( dir_message) ,
33
+ )
34
+ . subcommand (
35
+ SubCommand :: with_name ( "linkcheck" )
36
+ . about ( "Run linkcheck with mdBook 3" )
37
+ . arg_from_usage ( dir_message) ,
38
+ )
39
+ . get_matches ( ) ;
36
40
37
41
// Check which subcomamnd the user ran...
38
42
match matches. subcommand ( ) {
@@ -46,23 +50,35 @@ fn main() {
46
50
47
51
:: std:: process:: exit ( 101 ) ;
48
52
}
49
- } ,
53
+ }
50
54
( "linkcheck" , Some ( sub_matches) ) => {
51
55
if let Err ( err) = linkcheck ( sub_matches) {
52
56
eprintln ! ( "Error: {}" , err) ;
53
57
58
+ // HACK: ignore timeouts
59
+ #[ allow( unused_mut) ]
60
+ let mut actually_broken = false ;
61
+
54
62
#[ cfg( feature = "linkcheck" ) ]
55
63
{
56
64
if let Ok ( broken_links) = err. downcast :: < BrokenLinks > ( ) {
57
65
for cause in broken_links. links ( ) . iter ( ) {
58
66
eprintln ! ( "\t Caused By: {}" , cause) ;
67
+
68
+ if cause. contains ( "timed out" ) {
69
+ actually_broken = true ;
70
+ }
59
71
}
60
72
}
61
73
}
62
74
63
- :: std:: process:: exit ( 101 ) ;
75
+ if actually_broken {
76
+ std:: process:: exit ( 101 ) ;
77
+ } else {
78
+ std:: process:: exit ( 0 ) ;
79
+ }
64
80
}
65
- } ,
81
+ }
66
82
( _, _) => unreachable ! ( ) ,
67
83
} ;
68
84
}
0 commit comments