]> git.proxmox.com Git - rustc.git/blob - vendor/mdbook/src/cmd/command_prelude.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / mdbook / src / cmd / command_prelude.rs
1 //! Helpers for building the command-line arguments for commands.
2
3 pub use clap::{arg, Arg, ArgMatches, Command};
4 use std::path::PathBuf;
5
6 pub trait CommandExt: Sized {
7 fn _arg(self, arg: Arg) -> Self;
8
9 fn arg_dest_dir(self) -> Self {
10 self._arg(
11 Arg::new("dest-dir")
12 .short('d')
13 .long("dest-dir")
14 .value_name("dest-dir")
15 .value_parser(clap::value_parser!(PathBuf))
16 .help(
17 "Output directory for the book\n\
18 Relative paths are interpreted relative to the book's root directory.\n\
19 If omitted, mdBook uses build.build-dir from book.toml \
20 or defaults to `./book`.",
21 ),
22 )
23 }
24
25 fn arg_root_dir(self) -> Self {
26 self._arg(
27 Arg::new("dir")
28 .help(
29 "Root directory for the book\n\
30 (Defaults to the current directory when omitted)",
31 )
32 .value_parser(clap::value_parser!(PathBuf)),
33 )
34 }
35
36 fn arg_open(self) -> Self {
37 self._arg(arg!(-o --open "Opens the compiled book in a web browser"))
38 }
39 }
40
41 impl CommandExt for Command {
42 fn _arg(self, arg: Arg) -> Self {
43 self.arg(arg)
44 }
45 }