diff options
| author | bors <bors@rust-lang.org> | 2022-07-10 03:45:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-10 03:45:08 +0000 |
| commit | 100142b258e570a2c8fbd713eecc77a8fe6c0435 (patch) | |
| tree | 90cbf26260ff85d3ac3753809c8c717ce24ca8a0 /src | |
| parent | 17355a3b9f30e16870a1890033bd13463c664f81 (diff) | |
| parent | 4a7b773a027cd8234c83828fba8f2f4f572da8c1 (diff) | |
| download | rust-100142b258e570a2c8fbd713eecc77a8fe6c0435.tar.gz rust-100142b258e570a2c8fbd713eecc77a8fe6c0435.zip | |
Auto merge of #98213 - notriddle:notriddle/clap-3, r=Mark-Simulacrum
Bump to clap 3 This PR, along with several others, will entirely remove the Clap 2 dependency from the rust source tree. * https://github.com/rust-lang/rust-installer/pull/114 * https://github.com/rust-lang/rls/pull/1779 This PR includes a submodule bump for rust-installer, which includes the following PRs: * https://github.com/rust-lang/rust-installer/pull/114 * https://github.com/rust-lang/rust-installer/pull/113 * https://github.com/rust-lang/rust-installer/pull/115
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/tool.rs | 2 | ||||
| m--------- | src/tools/rust-installer | 0 | ||||
| -rw-r--r-- | src/tools/rustbook/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/tools/rustbook/src/main.rs | 41 |
4 files changed, 24 insertions, 21 deletions
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 23832b6c43e..f659ccbe250 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -367,7 +367,7 @@ bootstrap_tool!( Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true; BuildManifest, "src/tools/build-manifest", "build-manifest"; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client"; - RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true; + RustInstaller, "src/tools/rust-installer", "rust-installer", is_external_tool = true; RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes"; ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors"; LintDocs, "src/tools/lint-docs", "lint-docs"; diff --git a/src/tools/rust-installer b/src/tools/rust-installer -Subproject 5254dbfd25d5284728ab624dca1969d61427a0d +Subproject 300b5ec61ef38855a07e6bb4955a37aa1c414c0 diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index f074eb941dc..bd08e0ede0b 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -clap = "2.25.0" +clap = "3.1.1" env_logger = "0.7.1" [dependencies.mdbook] diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 63d84ae9732..3c7dc0183d7 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -3,54 +3,57 @@ use clap::crate_version; use std::env; use std::path::{Path, PathBuf}; -use clap::{App, AppSettings, ArgMatches, SubCommand}; +use clap::{arg, ArgMatches, Command}; use mdbook::errors::Result as Result3; use mdbook::MDBook; fn main() { + let crate_version = format!("v{}", crate_version!()); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); - let d_message = "-d, --dest-dir=[dest-dir] -'The output directory for your book{n}(Defaults to ./book when omitted)'"; - let dir_message = "[dir] -'A directory for your book{n}(Defaults to Current Directory when omitted)'"; + 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)"); - let matches = App::new("rustbook") + let matches = Command::new("rustbook") .about("Build a book with mdBook") .author("Steve Klabnik <steve@steveklabnik.com>") - .version(&*format!("v{}", crate_version!())) - .setting(AppSettings::SubcommandRequired) + .version(&*crate_version) + .subcommand_required(true) + .arg_required_else_help(true) .subcommand( - SubCommand::with_name("build") + Command::new("build") .about("Build the book from the markdown files") - .arg_from_usage(d_message) - .arg_from_usage(dir_message), + .arg(d_arg) + .arg(&dir_arg), ) .subcommand( - SubCommand::with_name("test") + Command::new("test") .about("Tests that a book's Rust code samples compile") - .arg_from_usage(dir_message), + .arg(dir_arg), ) .get_matches(); // Check which subcomamnd the user ran... match matches.subcommand() { - ("build", Some(sub_matches)) => { + Some(("build", sub_matches)) => { if let Err(e) = build(sub_matches) { handle_error(e); } } - ("test", Some(sub_matches)) => { + Some(("test", sub_matches)) => { if let Err(e) = test(sub_matches) { handle_error(e); } } - (_, _) => unreachable!(), + _ => unreachable!(), }; } // Build command implementation -pub fn build(args: &ArgMatches<'_>) -> Result3<()> { +pub fn build(args: &ArgMatches) -> Result3<()> { let book_dir = get_book_dir(args); let mut book = load_book(&book_dir)?; @@ -66,13 +69,13 @@ pub fn build(args: &ArgMatches<'_>) -> Result3<()> { Ok(()) } -fn test(args: &ArgMatches<'_>) -> Result3<()> { +fn test(args: &ArgMatches) -> Result3<()> { let book_dir = get_book_dir(args); let mut book = load_book(&book_dir)?; book.test(vec![]) } -fn get_book_dir(args: &ArgMatches<'_>) -> PathBuf { +fn get_book_dir(args: &ArgMatches) -> PathBuf { if let Some(dir) = args.value_of("dir") { // Check if path is relative from current dir, or absolute... let p = Path::new(dir); |
