From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- vendor/mdbook/src/cmd/command_prelude.rs | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 vendor/mdbook/src/cmd/command_prelude.rs (limited to 'vendor/mdbook/src/cmd/command_prelude.rs') diff --git a/vendor/mdbook/src/cmd/command_prelude.rs b/vendor/mdbook/src/cmd/command_prelude.rs new file mode 100644 index 000000000..b6362e603 --- /dev/null +++ b/vendor/mdbook/src/cmd/command_prelude.rs @@ -0,0 +1,45 @@ +//! Helpers for building the command-line arguments for commands. + +pub use clap::{arg, Arg, ArgMatches, Command}; +use std::path::PathBuf; + +pub trait CommandExt: Sized { + fn _arg(self, arg: Arg) -> Self; + + fn arg_dest_dir(self) -> Self { + self._arg( + Arg::new("dest-dir") + .short('d') + .long("dest-dir") + .value_name("dest-dir") + .value_parser(clap::value_parser!(PathBuf)) + .help( + "Output directory for the book\n\ + Relative paths are interpreted relative to the book's root directory.\n\ + If omitted, mdBook uses build.build-dir from book.toml \ + or defaults to `./book`.", + ), + ) + } + + fn arg_root_dir(self) -> Self { + self._arg( + Arg::new("dir") + .help( + "Root directory for the book\n\ + (Defaults to the current directory when omitted)", + ) + .value_parser(clap::value_parser!(PathBuf)), + ) + } + + fn arg_open(self) -> Self { + self._arg(arg!(-o --open "Opens the compiled book in a web browser")) + } +} + +impl CommandExt for Command { + fn _arg(self, arg: Arg) -> Self { + self.arg(arg) + } +} -- cgit v1.2.3