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 --- src/tools/rustbook/Cargo.toml | 4 ++-- src/tools/rustbook/src/main.rs | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/tools/rustbook') diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index 33c051804..b296aa2f4 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -5,10 +5,10 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -clap = "3.1.1" +clap = "4.0.32" env_logger = "0.7.1" [dependencies.mdbook] -version = "0.4.21" +version = "0.4.25" default-features = false features = ["search"] diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 3c7dc0183..1368ec653 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -9,18 +9,21 @@ use mdbook::errors::Result as Result3; use mdbook::MDBook; fn main() { - let crate_version = format!("v{}", crate_version!()); + let crate_version = concat!("v", crate_version!()); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); let d_arg = arg!(-d --"dest-dir" "The output directory for your book\n(Defaults to ./book when omitted)") - .required(false); - let dir_arg = arg!([dir] -"A directory for your book\n(Defaults to Current Directory when omitted)"); + .required(false) + .value_parser(clap::value_parser!(PathBuf)); + + let dir_arg = arg!([dir] "Root directory for the book\n\ + (Defaults to the current directory when omitted)") + .value_parser(clap::value_parser!(PathBuf)); let matches = Command::new("rustbook") .about("Build a book with mdBook") .author("Steve Klabnik ") - .version(&*crate_version) + .version(crate_version) .subcommand_required(true) .arg_required_else_help(true) .subcommand( @@ -60,8 +63,8 @@ pub fn build(args: &ArgMatches) -> Result3<()> { // Set this to allow us to catch bugs in advance. book.config.build.create_missing = false; - if let Some(dest_dir) = args.value_of("dest-dir") { - book.config.build.build_dir = PathBuf::from(dest_dir); + if let Some(dest_dir) = args.get_one::("dest-dir") { + book.config.build.build_dir = dest_dir.into(); } book.build()?; @@ -76,10 +79,9 @@ fn test(args: &ArgMatches) -> Result3<()> { } fn get_book_dir(args: &ArgMatches) -> PathBuf { - if let Some(dir) = args.value_of("dir") { + if let Some(p) = args.get_one::("dir") { // Check if path is relative from current dir, or absolute... - let p = Path::new(dir); - if p.is_relative() { env::current_dir().unwrap().join(dir) } else { p.to_path_buf() } + if p.is_relative() { env::current_dir().unwrap().join(p) } else { p.to_path_buf() } } else { env::current_dir().unwrap() } -- cgit v1.2.3