1- use clap:: { crate_version} ;
1+ use clap:: crate_version;
22
33use std:: env;
44use std:: path:: { Path , PathBuf } ;
55
6- use clap:: { App , ArgMatches , SubCommand , AppSettings } ;
6+ use clap:: { App , AppSettings , ArgMatches , SubCommand } ;
77
8+ use mdbook:: errors:: Result as Result3 ;
89use mdbook:: MDBook ;
9- use mdbook:: errors:: { Result as Result3 } ;
1010
11+ use failure:: Error ;
1112#[ cfg( feature = "linkcheck" ) ]
1213use mdbook:: renderer:: RenderContext ;
1314#[ cfg( feature = "linkcheck" ) ]
1415use mdbook_linkcheck:: { self , errors:: BrokenLinks } ;
15- use failure:: Error ;
1616
1717fn main ( ) {
1818 let d_message = "-d, --dest-dir=[dest-dir]
@@ -21,18 +21,22 @@ fn main() {
2121'A directory for your book{n}(Defaults to Current Directory when omitted)'" ;
2222
2323 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 ( ) ;
3640
3741 // Check which subcomamnd the user ran...
3842 match matches. subcommand ( ) {
@@ -46,23 +50,35 @@ fn main() {
4650
4751 :: std:: process:: exit ( 101 ) ;
4852 }
49- } ,
53+ }
5054 ( "linkcheck" , Some ( sub_matches) ) => {
5155 if let Err ( err) = linkcheck ( sub_matches) {
5256 eprintln ! ( "Error: {}" , err) ;
5357
58+ // HACK: ignore timeouts
59+ #[ allow( unused_mut) ]
60+ let mut actually_broken = false ;
61+
5462 #[ cfg( feature = "linkcheck" ) ]
5563 {
5664 if let Ok ( broken_links) = err. downcast :: < BrokenLinks > ( ) {
5765 for cause in broken_links. links ( ) . iter ( ) {
5866 eprintln ! ( "\t Caused By: {}" , cause) ;
67+
68+ if cause. contains ( "timed out" ) {
69+ actually_broken = true ;
70+ }
5971 }
6072 }
6173 }
6274
63- :: std:: process:: exit ( 101 ) ;
75+ if actually_broken {
76+ std:: process:: exit ( 101 ) ;
77+ } else {
78+ std:: process:: exit ( 0 ) ;
79+ }
6480 }
65- } ,
81+ }
6682 ( _, _) => unreachable ! ( ) ,
6783 } ;
6884}
0 commit comments