diff options
Diffstat (limited to 'vendor/mdbook/src/cmd/build.rs')
-rw-r--r-- | vendor/mdbook/src/cmd/build.rs | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/vendor/mdbook/src/cmd/build.rs b/vendor/mdbook/src/cmd/build.rs index 5fe73236c..14a9fec6e 100644 --- a/vendor/mdbook/src/cmd/build.rs +++ b/vendor/mdbook/src/cmd/build.rs @@ -1,28 +1,16 @@ +use super::command_prelude::*; use crate::{get_book_dir, open}; -use clap::{arg, App, Arg, ArgMatches}; use mdbook::errors::Result; use mdbook::MDBook; +use std::path::PathBuf; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("build") +pub fn make_subcommand() -> Command { + Command::new("build") .about("Builds a book from its markdown files") - .arg( - Arg::new("dest-dir") - .short('d') - .long("dest-dir") - .value_name("dest-dir") - .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`.", - ), - ) - .arg(arg!([dir] - "Root directory for the book{n}\ - (Defaults to the Current Directory when omitted)" - )) - .arg(arg!(-o --open "Opens the compiled book in a web browser")) + .arg_dest_dir() + .arg_root_dir() + .arg_open() } // Build command implementation @@ -30,13 +18,13 @@ pub fn execute(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); let mut book = MDBook::load(&book_dir)?; - if let Some(dest_dir) = args.value_of("dest-dir") { + if let Some(dest_dir) = args.get_one::<PathBuf>("dest-dir") { book.config.build.build_dir = dest_dir.into(); } book.build()?; - if args.is_present("open") { + if args.get_flag("open") { // FIXME: What's the right behaviour if we don't use the HTML renderer? let path = book.build_dir_for("html").join("index.html"); if !path.exists() { |