1
1
#[ cfg( feature = "watch" ) ]
2
2
use super :: watch;
3
3
use crate :: { get_book_dir, open} ;
4
- use clap:: { App , Arg , ArgMatches , SubCommand } ;
4
+ use clap:: { arg , App , Arg , ArgMatches } ;
5
5
use futures_util:: sink:: SinkExt ;
6
6
use futures_util:: StreamExt ;
7
7
use mdbook:: errors:: * ;
@@ -18,37 +18,43 @@ use warp::Filter;
18
18
const LIVE_RELOAD_ENDPOINT : & str = "__livereload" ;
19
19
20
20
// 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" )
23
23
. 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
+ ) ,
32
34
)
35
+ . arg ( arg ! ( [ dir]
36
+ "Root directory for the book{n}\
37
+ (Defaults to the Current Directory when omitted)"
38
+ ) )
33
39
. arg (
34
- Arg :: with_name ( "hostname" )
35
- . short ( "n" )
40
+ Arg :: new ( "hostname" )
41
+ . short ( 'n' )
36
42
. long ( "hostname" )
37
43
. takes_value ( true )
38
44
. default_value ( "localhost" )
39
- . empty_values ( false )
45
+ . forbid_empty_values ( true )
40
46
. help ( "Hostname to listen on for HTTP connections" ) ,
41
47
)
42
48
. arg (
43
- Arg :: with_name ( "port" )
44
- . short ( "p" )
49
+ Arg :: new ( "port" )
50
+ . short ( 'p' )
45
51
. long ( "port" )
46
52
. takes_value ( true )
47
53
. default_value ( "3000" )
48
- . empty_values ( false )
54
+ . forbid_empty_values ( true )
49
55
. help ( "Port to use for HTTP connections" ) ,
50
56
)
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" ) )
52
58
}
53
59
54
60
// Serve command implementation
0 commit comments