11#[ cfg( feature = "watch" ) ]
22use super :: watch;
33use crate :: { get_book_dir, open} ;
4- use clap:: { App , Arg , ArgMatches , SubCommand } ;
4+ use clap:: { arg , App , Arg , ArgMatches } ;
55use futures_util:: sink:: SinkExt ;
66use futures_util:: StreamExt ;
77use mdbook:: errors:: * ;
@@ -18,37 +18,43 @@ use warp::Filter;
1818const LIVE_RELOAD_ENDPOINT : & str = "__livereload" ;
1919
2020// Create clap subcommand arguments
21- pub fn make_subcommand < ' a , ' b > ( ) -> App < ' a , ' b > {
22- SubCommand :: with_name ( "serve" )
21+ pub fn make_subcommand < ' help > ( ) -> App < ' help > {
22+ App :: new ( "serve" )
2323 . about ( "Serves a book at http://localhost:3000, and rebuilds it on changes" )
24- . arg_from_usage (
25- "-d, --dest-dir=[dest-dir] 'Output directory for the book{n}\
26- Relative paths are interpreted relative to the book's root directory.{n}\
27- If omitted, mdBook uses build.build-dir from book.toml or defaults to `./book`.'",
28- )
29- . arg_from_usage (
30- "[dir] 'Root directory for the book{n}\
31- (Defaults to the Current Directory when omitted)'",
24+ . arg (
25+ Arg :: new ( "dest-dir" )
26+ . short ( 'd' )
27+ . long ( "dest-dir" )
28+ . value_name ( "dest-dir" )
29+ . help (
30+ "Output directory for the book{n}\
31+ Relative paths are interpreted relative to the book's root directory.{n}\
32+ If omitted, mdBook uses build.build-dir from book.toml or defaults to `./book`.",
33+ ) ,
3234 )
35+ . arg ( arg ! ( [ dir]
36+ "Root directory for the book{n}\
37+ (Defaults to the Current Directory when omitted)"
38+ ) )
3339 . arg (
34- Arg :: with_name ( "hostname" )
35- . short ( "n" )
40+ Arg :: new ( "hostname" )
41+ . short ( 'n' )
3642 . long ( "hostname" )
3743 . takes_value ( true )
3844 . default_value ( "localhost" )
39- . empty_values ( false )
45+ . forbid_empty_values ( true )
4046 . help ( "Hostname to listen on for HTTP connections" ) ,
4147 )
4248 . arg (
43- Arg :: with_name ( "port" )
44- . short ( "p" )
49+ Arg :: new ( "port" )
50+ . short ( 'p' )
4551 . long ( "port" )
4652 . takes_value ( true )
4753 . default_value ( "3000" )
48- . empty_values ( false )
54+ . forbid_empty_values ( true )
4955 . help ( "Port to use for HTTP connections" ) ,
5056 )
51- . arg_from_usage ( "-o, --open ' Opens the book server in a web browser'" )
57+ . arg ( arg ! ( -o --open " Opens the compiled book in a web browser" ) )
5258}
5359
5460// Serve command implementation
0 commit comments