summaryrefslogtreecommitdiffstats
path: root/src/tools/rustbook
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /src/tools/rustbook
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rustbook')
-rw-r--r--src/tools/rustbook/Cargo.toml4
-rw-r--r--src/tools/rustbook/src/main.rs22
2 files changed, 14 insertions, 12 deletions
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" <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 <steve@steveklabnik.com>")
- .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::<PathBuf>("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::<PathBuf>("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()
}