From a62777880986f4525fd7a3a21301ac1ecc020e59 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 11 Feb 2022 16:17:15 -0600 Subject: [PATCH 1/7] refactor: Generalize test file name --- src/build/arg_tests.rs | 8 -------- src/build/mod.rs | 4 +--- src/build/{app_tests.rs => tests.rs} | 8 ++++++++ 3 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 src/build/arg_tests.rs rename src/build/{app_tests.rs => tests.rs} (85%) diff --git a/src/build/arg_tests.rs b/src/build/arg_tests.rs deleted file mode 100644 index 6a6506e43f9..00000000000 --- a/src/build/arg_tests.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::Arg; - -// This test will *fail to compile* if Arg is not Send + Sync -#[test] -fn arg_send_sync() { - fn foo(_: T) {} - foo(Arg::new("test")) -} diff --git a/src/build/mod.rs b/src/build/mod.rs index 06ccb7a8930..b7c7935b018 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -19,9 +19,7 @@ mod regex; mod debug_asserts; #[cfg(test)] -mod app_tests; -#[cfg(test)] -mod arg_tests; +mod tests; pub use app::App; pub use app_settings::{AppFlags, AppSettings}; diff --git a/src/build/app_tests.rs b/src/build/tests.rs similarity index 85% rename from src/build/app_tests.rs rename to src/build/tests.rs index 8317c8aa093..946593d0975 100644 --- a/src/build/app_tests.rs +++ b/src/build/tests.rs @@ -1,4 +1,5 @@ use crate::App; +use crate::Arg; #[test] fn propagate_version() { @@ -46,3 +47,10 @@ fn issue_2090() { .unwrap() .is_disable_version_flag_set()); } + +// This test will *fail to compile* if Arg is not Send + Sync +#[test] +fn arg_send_sync() { + fn foo(_: T) {} + foo(Arg::new("test")) +} From 44d85344a9e3c3adf913973adb73388d48de064f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 14 Feb 2022 15:28:38 -0600 Subject: [PATCH 2/7] refactor: Be consistent in mod visibility --- src/build/mod.rs | 9 +++++---- src/output/help.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/build/mod.rs b/src/build/mod.rs index b7c7935b018..386e1be32f6 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1,10 +1,9 @@ #[macro_use] mod macros; -pub mod app; -pub mod arg; - +mod app; mod app_settings; +mod arg; mod arg_group; mod arg_predicate; mod arg_settings; @@ -25,10 +24,12 @@ pub use app::App; pub use app_settings::{AppFlags, AppSettings}; pub use arg::Arg; pub use arg_group::ArgGroup; -pub(crate) use arg_predicate::ArgPredicate; pub use arg_settings::{ArgFlags, ArgSettings}; pub use possible_value::PossibleValue; pub use value_hint::ValueHint; #[cfg(feature = "regex")] pub use self::regex::RegexRef; + +pub(crate) use arg::display_arg_val; +pub(crate) use arg_predicate::ArgPredicate; diff --git a/src/output/help.rs b/src/output/help.rs index b1faad889d9..e14a0828a24 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -9,7 +9,7 @@ use std::{ // Internal use crate::{ - build::{arg::display_arg_val, App, Arg}, + build::{display_arg_val, App, Arg}, output::{fmt::Colorizer, Usage}, }; From 06b269a85a7e96792438c052866df64c3b8d8aa5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 14 Feb 2022 15:29:26 -0600 Subject: [PATCH 3/7] refactor: Rename Apps file --- src/build/{app.rs => command.rs} | 0 src/build/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/build/{app.rs => command.rs} (100%) diff --git a/src/build/app.rs b/src/build/command.rs similarity index 100% rename from src/build/app.rs rename to src/build/command.rs diff --git a/src/build/mod.rs b/src/build/mod.rs index 386e1be32f6..a1b80555793 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1,12 +1,12 @@ #[macro_use] mod macros; -mod app; mod app_settings; mod arg; mod arg_group; mod arg_predicate; mod arg_settings; +mod command; mod possible_value; mod usage_parser; mod value_hint; @@ -20,11 +20,11 @@ mod debug_asserts; #[cfg(test)] mod tests; -pub use app::App; pub use app_settings::{AppFlags, AppSettings}; pub use arg::Arg; pub use arg_group::ArgGroup; pub use arg_settings::{ArgFlags, ArgSettings}; +pub use command::App; pub use possible_value::PossibleValue; pub use value_hint::ValueHint; From 524e164c31a39bc37e90847e8b0ab14264b537b7 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 14 Feb 2022 15:32:07 -0600 Subject: [PATCH 4/7] fix: Rename App to Command --- src/build/command.rs | 3 +++ src/build/mod.rs | 1 + src/lib.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/build/command.rs b/src/build/command.rs index bcc36ea2d4d..dc25447fdca 100644 --- a/src/build/command.rs +++ b/src/build/command.rs @@ -61,6 +61,9 @@ use crate::build::debug_asserts::assert_app; /// // Your program logic starts here... /// ``` /// [`App::get_matches`]: App::get_matches() +pub type Command<'help> = App<'help>; + +/// Deprecated, replaced with [`Command`] #[derive(Debug, Clone, PartialEq, Eq)] pub struct App<'help> { id: Id, diff --git a/src/build/mod.rs b/src/build/mod.rs index a1b80555793..d7d4920ae6d 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -25,6 +25,7 @@ pub use arg::Arg; pub use arg_group::ArgGroup; pub use arg_settings::{ArgFlags, ArgSettings}; pub use command::App; +pub use command::Command; pub use possible_value::PossibleValue; pub use value_hint::ValueHint; diff --git a/src/lib.rs b/src/lib.rs index 369ee0d7d58..54b29c67aa6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,7 @@ #[cfg(not(feature = "std"))] compile_error!("`std` feature is currently required to build `clap`"); +pub use crate::build::Command; pub use crate::build::{ App, AppFlags, AppSettings, Arg, ArgFlags, ArgGroup, ArgSettings, PossibleValue, ValueHint, }; From c4144d7d6c174088ea9cc99652f120cb0af88b86 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 11 Feb 2022 21:48:29 -0600 Subject: [PATCH 5/7] docs: Update App references to Command --- README.md | 6 +- benches/01_default.rs | 6 +- benches/02_simple.rs | 16 +- benches/03_complex.rs | 10 +- benches/04_new_help.rs | 42 +- benches/05_ripgrep.rs | 12 +- benches/06_rustup.rs | 100 +-- clap_complete/Cargo.toml | 2 +- clap_complete/examples/bash_completion.rs | 8 +- clap_complete/examples/value_hints.rs | 8 +- clap_complete/examples/value_hints_derive.rs | 6 +- clap_complete/src/generator/mod.rs | 34 +- clap_complete/src/generator/utils.rs | 38 +- clap_complete/src/lib.rs | 8 +- clap_complete/src/shells/bash.rs | 10 +- clap_complete/src/shells/elvish.rs | 4 +- clap_complete/src/shells/fish.rs | 9 +- clap_complete/src/shells/powershell.rs | 4 +- clap_complete/src/shells/shell.rs | 2 +- clap_complete/src/shells/zsh.rs | 31 +- clap_complete/tests/completions/bash.rs | 18 +- clap_complete/tests/completions/elvish.rs | 18 +- clap_complete/tests/completions/fish.rs | 28 +- clap_complete/tests/completions/mod.rs | 4 +- clap_complete/tests/completions/powershell.rs | 18 +- clap_complete/tests/completions/zsh.rs | 34 +- clap_complete/tests/generate_completions.rs | 6 +- clap_complete/tests/value_hints.rs | 6 +- clap_complete_fig/examples/fig_completion.rs | 8 +- clap_complete_fig/src/fig.rs | 6 +- clap_complete_fig/tests/completions/fig.rs | 28 +- clap_complete_fig/tests/completions/mod.rs | 4 +- .../tests/generate_completions.rs | 6 +- clap_complete_fig/tests/value_hints.rs | 6 +- clap_derive/src/derives/args.rs | 4 +- clap_derive/src/derives/into_app.rs | 16 +- clap_derive/src/derives/subcommand.rs | 8 +- clap_derive/src/dummies.rs | 12 +- clap_derive/src/lib.rs | 2 +- clap_derive/src/parse.rs | 4 +- clap_generate/src/lib.rs | 4 +- clap_generate/tests/warning.rs | 6 +- clap_mangen/README.md | 4 +- clap_mangen/examples/man.rs | 6 +- clap_mangen/src/lib.rs | 10 +- clap_mangen/src/render.rs | 18 +- clap_mangen/tests/generate.rs | 6 +- docs/FAQ.md | 2 +- examples/cargo-example.rs | 2 +- examples/derive_ref/README.md | 42 +- examples/git.rs | 10 +- examples/multicall-busybox.md | 2 +- examples/multicall-busybox.rs | 12 +- examples/multicall-hostname.md | 2 +- examples/multicall-hostname.rs | 8 +- examples/pacman.rs | 8 +- examples/tutorial_builder/01_quick.rs | 4 +- examples/tutorial_builder/02_apps.rs | 4 +- .../tutorial_builder/03_04_subcommands.rs | 4 +- examples/tutorial_builder/05_01_assert.rs | 2 +- examples/tutorial_builder/README.md | 12 +- examples/tutorial_derive/README.md | 10 +- src/build/app_settings.rs | 186 ++-- src/build/arg.rs | 536 ++++++------ src/build/arg_group.rs | 52 +- src/build/command.rs | 800 +++++++++--------- src/build/debug_asserts.rs | 80 +- src/build/mod.rs | 4 +- src/build/tests.rs | 18 +- src/build/usage_parser.rs | 8 +- src/build/value_hint.rs | 4 +- src/derive.rs | 54 +- src/error/kind.rs | 96 +-- src/error/mod.rs | 72 +- src/lib.rs | 17 +- src/macros.rs | 34 +- src/output/help.rs | 27 +- src/output/usage.rs | 6 +- src/parse/arg_matcher.rs | 4 +- src/parse/features/suggestions.rs | 4 +- src/parse/matches/arg_matches.rs | 158 ++-- src/parse/parser.rs | 6 +- src/parse/validator.rs | 6 +- src/util/color.rs | 12 +- tests/builder/app_settings.rs | 214 ++--- tests/builder/arg_aliases.rs | 22 +- tests/builder/arg_aliases_short.rs | 22 +- tests/builder/arg_matcher_assertions.rs | 10 +- tests/builder/borrowed.rs | 6 +- tests/builder/cargo.rs | 12 +- tests/builder/conflicts.rs | 40 +- tests/builder/default_missing_vals.rs | 24 +- tests/builder/default_vals.rs | 96 +-- tests/builder/delimiters.rs | 16 +- tests/builder/derive_order.rs | 24 +- tests/builder/display_order.rs | 4 +- tests/builder/double_require.rs | 6 +- tests/builder/empty_values.rs | 22 +- tests/builder/env.rs | 36 +- tests/builder/error.rs | 8 +- tests/builder/flag_subcommands.rs | 154 ++-- tests/builder/flags.rs | 22 +- tests/builder/global_args.rs | 40 +- tests/builder/grouped_values.rs | 20 +- tests/builder/groups.rs | 40 +- tests/builder/help.rs | 254 +++--- tests/builder/help_env.rs | 18 +- tests/builder/hidden_args.rs | 26 +- tests/builder/ignore_errors.rs | 14 +- tests/builder/indices.rs | 24 +- tests/builder/multiple_occurrences.rs | 24 +- tests/builder/multiple_values.rs | 124 +-- tests/builder/opts.rs | 72 +- tests/builder/positionals.rs | 54 +- tests/builder/posix_compatible.rs | 56 +- tests/builder/possible_values.rs | 42 +- tests/builder/propagate_globals.rs | 10 +- tests/builder/regex.rs | 6 +- tests/builder/require.rs | 142 ++-- tests/builder/subcommands.rs | 120 +-- tests/builder/template_help.rs | 16 +- tests/builder/tests.rs | 6 +- tests/builder/unicode.rs | 2 +- tests/builder/unique_args.rs | 12 +- tests/builder/utf16.rs | 26 +- tests/builder/utf8.rs | 66 +- tests/builder/utils.rs | 10 +- tests/builder/validators.rs | 10 +- tests/builder/version.rs | 20 +- tests/derive/doc_comments_help.rs | 10 +- tests/derive_ui/raw.stderr | 4 +- tests/yaml.rs | 8 +- 132 files changed, 2505 insertions(+), 2463 deletions(-) diff --git a/README.md b/README.md index 4cf89ca61db..796507a8b9b 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Why use the procedural [Builder API](https://github.com/clap-rs/clap/blob/v3.0.1 - [wild](https://crates.io/crates/wild) for supporting wildcards (`*`) on Windows like you do Linux - [argfile](https://crates.io/crates/argfile) for loading additional arguments from a file (aka response files) -- [shadow-rs](https://crates.io/crates/shadow-rs) for generating `App::long_version` +- [shadow-rs](https://crates.io/crates/shadow-rs) for generating `Command::long_version` - [clap_mangen](https://crates.io/crates/clap_mangen) for generating man page source (roff) - [clap_complete](https://crates.io/crates/clap_complete) for shell completion support - [clap-verbosity-flag](https://crates.io/crates/clap-verbosity-flag) @@ -150,8 +150,8 @@ Why use the procedural [Builder API](https://github.com/clap-rs/clap/blob/v3.0.1 **Warning:** These may contain breaking changes between minor releases. -* **unstable-replace**: Enable [`App::replace`](https://github.com/clap-rs/clap/issues/2836) -* **unstable-multicall**: Enable [`App::multicall`](https://github.com/clap-rs/clap/issues/2861) +* **unstable-replace**: Enable [`Command::replace`](https://github.com/clap-rs/clap/issues/2836) +* **unstable-multicall**: Enable [`Command::multicall`](https://github.com/clap-rs/clap/issues/2861) * **unstable-grouped**: Enable [`ArgMatches::grouped_values_of`](https://github.com/clap-rs/clap/issues/2924) ## Sponsors diff --git a/benches/01_default.rs b/benches/01_default.rs index 07e3ad218f8..620b32b818f 100644 --- a/benches/01_default.rs +++ b/benches/01_default.rs @@ -1,13 +1,13 @@ -use clap::App; +use clap::Command; use criterion::{criterion_group, criterion_main, Criterion}; pub fn build_empty(c: &mut Criterion) { - c.bench_function("build_empty", |b| b.iter(|| App::new("claptests"))); + c.bench_function("build_empty", |b| b.iter(|| Command::new("claptests"))); } pub fn parse_empty(c: &mut Criterion) { c.bench_function("parse_empty", |b| { - b.iter(|| App::new("claptests").get_matches_from(vec![""])) + b.iter(|| Command::new("claptests").get_matches_from(vec![""])) }); } diff --git a/benches/02_simple.rs b/benches/02_simple.rs index 46a725bbb5e..667d02f873c 100644 --- a/benches/02_simple.rs +++ b/benches/02_simple.rs @@ -1,9 +1,9 @@ -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; use criterion::{criterion_group, criterion_main, Criterion}; macro_rules! create_app { () => {{ - App::new("claptests") + Command::new("claptests") .version("0.1") .about("tests clap library") .author("Kevin K. ") @@ -19,7 +19,7 @@ pub fn build_simple(c: &mut Criterion) { pub fn build_with_flag(c: &mut Criterion) { c.bench_function("build_with_flag", |b| { - b.iter(|| App::new("claptests").arg(arg!(-s --some "something"))) + b.iter(|| Command::new("claptests").arg(arg!(-s --some "something"))) }); } @@ -27,14 +27,14 @@ pub fn build_with_flag_ref(c: &mut Criterion) { c.bench_function("build_with_flag_ref", |b| { b.iter(|| { let arg = arg!(-s --some "something"); - App::new("claptests").arg(&arg) + Command::new("claptests").arg(&arg) }) }); } pub fn build_with_opt(c: &mut Criterion) { c.bench_function("build_with_opt", |b| { - b.iter(|| App::new("claptests").arg(arg!(-s --some "something"))) + b.iter(|| Command::new("claptests").arg(arg!(-s --some "something"))) }); } @@ -42,14 +42,14 @@ pub fn build_with_opt_ref(c: &mut Criterion) { c.bench_function("build_with_opt_ref", |b| { b.iter(|| { let arg = arg!(-s --some "something"); - App::new("claptests").arg(&arg) + Command::new("claptests").arg(&arg) }) }); } pub fn build_with_pos(c: &mut Criterion) { c.bench_function("build_with_pos", |b| { - b.iter(|| App::new("claptests").arg(Arg::new("some"))) + b.iter(|| Command::new("claptests").arg(Arg::new("some"))) }); } @@ -57,7 +57,7 @@ pub fn build_with_pos_ref(c: &mut Criterion) { c.bench_function("build_with_pos_ref", |b| { b.iter(|| { let arg = Arg::new("some"); - App::new("claptests").arg(&arg) + Command::new("claptests").arg(&arg) }) }); } diff --git a/benches/03_complex.rs b/benches/03_complex.rs index 0e08a225d24..3ac81bb15dc 100644 --- a/benches/03_complex.rs +++ b/benches/03_complex.rs @@ -1,4 +1,4 @@ -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; use criterion::{criterion_group, criterion_main, Criterion}; static OPT3_VALS: [&str; 2] = ["fast", "slow"]; @@ -6,7 +6,7 @@ static POS3_VALS: [&str; 2] = ["vi", "emacs"]; macro_rules! create_app { () => {{ - App::new("claptests") + Command::new("claptests") .version("0.1") .about("tests clap library") .author("Kevin K. ") @@ -35,7 +35,7 @@ macro_rules! create_app { arg!(--maxvals3 ... "Tests 3 max vals").max_values(3).multiple_values(true).required(false), ]) .subcommand( - App::new("subcmd") + Command::new("subcmd") .about("tests subcommands") .version("0.1") .author("Kevin K. ") @@ -48,7 +48,7 @@ macro_rules! create_app { pub fn build_from_builder(c: &mut Criterion) { c.bench_function("build_from_builder", |b| { b.iter(|| { - App::new("claptests") + Command::new("claptests") .version("0.1") .about("tests clap library") .author("Kevin K. ") @@ -141,7 +141,7 @@ pub fn build_from_builder(c: &mut Criterion) { .max_values(3), ) .subcommand( - App::new("subcmd") + Command::new("subcmd") .about("tests subcommands") .version("0.1") .author("Kevin K. ") diff --git a/benches/04_new_help.rs b/benches/04_new_help.rs index 7a8717304a3..5175d0a3075 100644 --- a/benches/04_new_help.rs +++ b/benches/04_new_help.rs @@ -1,17 +1,17 @@ -use clap::App; +use clap::Command; use clap::{arg, Arg}; use criterion::{criterion_group, criterion_main, Criterion}; use std::io::Cursor; -fn build_help(app: &mut App) -> String { +fn build_help(app: &mut Command) -> String { let mut buf = Cursor::new(Vec::with_capacity(50)); app.write_help(&mut buf).unwrap(); let content = buf.into_inner(); String::from_utf8(content).unwrap() } -fn app_example1<'c>() -> App<'c> { - App::new("MyApp") +fn app_example1<'c>() -> Command<'c> { + Command::new("MyApp") .version("1.0") .author("Kevin K. ") .about("Does awesome things") @@ -24,21 +24,21 @@ fn app_example1<'c>() -> App<'c> { .arg(arg!( "Sets an optional output file")) .arg(arg!(d: -d ... "Turn debugging information on")) .subcommand( - App::new("test") + Command::new("test") .about("does testing things") .arg(arg!(-l --list "lists test values")), ) } -fn app_example2<'c>() -> App<'c> { - App::new("MyApp") +fn app_example2<'c>() -> Command<'c> { + Command::new("MyApp") .version("1.0") .author("Kevin K. ") .about("Does awesome things") } -fn app_example3<'c>() -> App<'c> { - App::new("MyApp") +fn app_example3<'c>() -> Command<'c> { + Command::new("MyApp") .arg( Arg::new("debug") .help("turn on debugging information") @@ -64,8 +64,8 @@ fn app_example3<'c>() -> App<'c> { ) } -fn app_example4<'c>() -> App<'c> { - App::new("MyApp") +fn app_example4<'c>() -> Command<'c> { + Command::new("MyApp") .about("Parses an input file to do awesome things") .version("1.0") .author("Kevin K. ") @@ -89,8 +89,8 @@ fn app_example4<'c>() -> App<'c> { ) } -fn app_example5<'c>() -> App<'c> { - App::new("MyApp").arg( +fn app_example5<'c>() -> Command<'c> { + Command::new("MyApp").arg( Arg::new("awesome") .help("turns up the awesome") .short('a') @@ -99,8 +99,8 @@ fn app_example5<'c>() -> App<'c> { ) } -fn app_example6<'c>() -> App<'c> { - App::new("MyApp") +fn app_example6<'c>() -> Command<'c> { + Command::new("MyApp") .arg( Arg::new("input") .help("the input file to use") @@ -111,8 +111,8 @@ fn app_example6<'c>() -> App<'c> { .arg(Arg::new("config").help("the config file to use").index(2)) } -fn app_example7<'c>() -> App<'c> { - App::new("MyApp") +fn app_example7<'c>() -> Command<'c> { + Command::new("MyApp") .arg(Arg::new("config")) .arg(Arg::new("output")) .arg( @@ -129,8 +129,8 @@ fn app_example7<'c>() -> App<'c> { ) } -fn app_example8<'c>() -> App<'c> { - App::new("MyApp") +fn app_example8<'c>() -> Command<'c> { + Command::new("MyApp") .arg(Arg::new("config")) .arg(Arg::new("output")) .arg( @@ -147,8 +147,8 @@ fn app_example8<'c>() -> App<'c> { ) } -fn app_example10<'c>() -> App<'c> { - App::new("myapp").about("does awesome things").arg( +fn app_example10<'c>() -> Command<'c> { + Command::new("myapp").about("does awesome things").arg( Arg::new("CONFIG") .help("The config file to use (default is \"config.json\")") .short('c') diff --git a/benches/05_ripgrep.rs b/benches/05_ripgrep.rs index 3a7e4de6b4e..1c4a29f71b6 100644 --- a/benches/05_ripgrep.rs +++ b/benches/05_ripgrep.rs @@ -3,7 +3,7 @@ // // CLI used is adapted from ripgrep 48a8a3a691220f9e5b2b08f4051abe8655ea7e8a -use clap::{App, Arg}; +use clap::{Arg, Command}; use criterion::{criterion_group, criterion_main, Criterion}; use std::collections::HashMap; use std::io::Cursor; @@ -270,17 +270,17 @@ OPTIONS: {options}"; /// Build a clap application with short help strings. -fn app_short() -> App<'static> { +fn app_short() -> Command<'static> { app(false, |k| USAGES[k].short) } /// Build a clap application with long help strings. -fn app_long() -> App<'static> { +fn app_long() -> Command<'static> { app(true, |k| USAGES[k].long) } /// Build the help text of an application. -fn build_help(app: &mut App) -> String { +fn build_help(app: &mut Command) -> String { let mut buf = Cursor::new(Vec::with_capacity(50)); app.write_help(&mut buf).unwrap(); let content = buf.into_inner(); @@ -294,14 +294,14 @@ fn build_help(app: &mut App) -> String { /// /// This is an intentionally stand-alone module so that it can be used easily /// in a `build.rs` script to build shell completion files. -fn app(_next_line_help: bool, doc: F) -> App<'static> +fn app(_next_line_help: bool, doc: F) -> Command<'static> where F: Fn(&'static str) -> &'static str, { let arg = |name| Arg::new(name).help(doc(name)); let flag = |name| arg(name).long(name); - App::new("ripgrep") + Command::new("ripgrep") .author("BurntSushi") // simulating since it's only a bench .version("0.4.0") // Simulating .about(ABOUT) diff --git a/benches/06_rustup.rs b/benches/06_rustup.rs index dba5be60f3f..8d9c406e40d 100644 --- a/benches/06_rustup.rs +++ b/benches/06_rustup.rs @@ -2,7 +2,7 @@ // // CLI used is from rustup 408ed84f0e50511ed44a405dd91365e5da588790 -use clap::{App, AppSettings, Arg, ArgGroup}; +use clap::{AppSettings, Arg, ArgGroup, Command}; use criterion::{criterion_group, criterion_main, Criterion}; pub fn build_rustup(c: &mut Criterion) { @@ -21,8 +21,8 @@ pub fn parse_rustup_with_sc(c: &mut Criterion) { }); } -fn build_cli() -> App<'static> { - App::new("rustup") +fn build_cli() -> Command<'static> { + Command::new("rustup") .version("0.9.0") // Simulating .about("The Rust toolchain installer") .after_help(RUSTUP_HELP) @@ -35,19 +35,19 @@ fn build_cli() -> App<'static> { .long("verbose"), ) .subcommand( - App::new("show") + Command::new("show") .about("Show the active and installed toolchains") .after_help(SHOW_HELP), ) .subcommand( - App::new("install") + Command::new("install") .about("Update Rust toolchains") .after_help(TOOLCHAIN_INSTALL_HELP) .hide(true) // synonym for 'toolchain install' .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("update") + Command::new("update") .about("Update Rust toolchains") .after_help(UPDATE_HELP) .arg(Arg::new("toolchain").required(true)) @@ -59,104 +59,104 @@ fn build_cli() -> App<'static> { ), ) .subcommand( - App::new("default") + Command::new("default") .about("Set the default toolchain") .after_help(DEFAULT_HELP) .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("toolchain") + Command::new("toolchain") .about("Modify or query the installed toolchains") .after_help(TOOLCHAIN_HELP) .setting(AppSettings::DeriveDisplayOrder) // .setting(AppSettings::SubcommandRequiredElseHelp) - .subcommand(App::new("list").about("List installed toolchains")) + .subcommand(Command::new("list").about("List installed toolchains")) .subcommand( - App::new("install") + Command::new("install") .about("Install or update a given toolchain") .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("uninstall") + Command::new("uninstall") .about("Uninstall a toolchain") .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("link") + Command::new("link") .about("Create a custom toolchain by symlinking to a directory") .arg(Arg::new("toolchain").required(true)) .arg(Arg::new("path").required(true)), ) .subcommand( - App::new("update") + Command::new("update") .hide(true) // synonym for 'install' .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("add") + Command::new("add") .hide(true) // synonym for 'install' .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("remove") + Command::new("remove") .hide(true) // synonym for 'uninstall' .arg(Arg::new("toolchain").required(true)), ), ) .subcommand( - App::new("target") + Command::new("target") .about("Modify a toolchain's supported targets") .setting(AppSettings::DeriveDisplayOrder) // .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand( - App::new("list") + Command::new("list") .about("List installed and available targets") .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ) .subcommand( - App::new("add") + Command::new("add") .about("Add a target to a Rust toolchain") .arg(Arg::new("target").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ) .subcommand( - App::new("remove") + Command::new("remove") .about("Remove a target from a Rust toolchain") .arg(Arg::new("target").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ) .subcommand( - App::new("install") + Command::new("install") .hide(true) // synonym for 'add' .arg(Arg::new("target").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ) .subcommand( - App::new("uninstall") + Command::new("uninstall") .hide(true) // synonym for 'remove' .arg(Arg::new("target").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ), ) .subcommand( - App::new("component") + Command::new("component") .about("Modify a toolchain's installed components") .setting(AppSettings::DeriveDisplayOrder) // .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand( - App::new("list") + Command::new("list") .about("List installed and available components") .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ) .subcommand( - App::new("add") + Command::new("add") .about("Add a component to a Rust toolchain") .arg(Arg::new("component").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)) .arg(Arg::new("target").long("target").takes_value(true)), ) .subcommand( - App::new("remove") + Command::new("remove") .about("Remove a component from a Rust toolchain") .arg(Arg::new("component").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)) @@ -164,19 +164,19 @@ fn build_cli() -> App<'static> { ), ) .subcommand( - App::new("override") + Command::new("override") .about("Modify directory toolchain overrides") .after_help(OVERRIDE_HELP) .setting(AppSettings::DeriveDisplayOrder) // .setting(AppSettings::SubcommandRequiredElseHelp) - .subcommand(App::new("list").about("List directory toolchain overrides")) + .subcommand(Command::new("list").about("List directory toolchain overrides")) .subcommand( - App::new("set") + Command::new("set") .about("Set the override toolchain for a directory") .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("unset") + Command::new("unset") .about("Remove the override toolchain for a directory") .after_help(OVERRIDE_UNSET_HELP) .arg( @@ -192,12 +192,12 @@ fn build_cli() -> App<'static> { ), ) .subcommand( - App::new("add") + Command::new("add") .hide(true) // synonym for 'set' .arg(Arg::new("toolchain").required(true)), ) .subcommand( - App::new("remove") + Command::new("remove") .hide(true) // synonym for 'unset' .about("Remove the override toolchain for a directory") .arg(Arg::new("path").long("path").takes_value(true)) @@ -209,7 +209,7 @@ fn build_cli() -> App<'static> { ), ) .subcommand( - App::new("run") + Command::new("run") .about("Run a command with an environment configured for a given toolchain") .after_help(RUN_HELP) .trailing_var_arg(true) @@ -223,12 +223,12 @@ fn build_cli() -> App<'static> { ), ) .subcommand( - App::new("which") + Command::new("which") .about("Display which binary will be run for a given command") .arg(Arg::new("command").required(true)), ) .subcommand( - App::new("doc") + Command::new("doc") .about("Open the documentation for the current toolchain") .after_help(DOC_HELP) .arg( @@ -244,38 +244,42 @@ fn build_cli() -> App<'static> { .group(ArgGroup::new("page").args(&["book", "std"])), ) .subcommand( - App::new("man") + Command::new("man") .about("View the man page for a given command") .arg(Arg::new("command").required(true)) .arg(Arg::new("toolchain").long("toolchain").takes_value(true)), ) .subcommand( - App::new("self") + Command::new("self") .about("Modify the rustup installation") .setting(AppSettings::DeriveDisplayOrder) - .subcommand(App::new("update").about("Download and install updates to rustup")) + .subcommand(Command::new("update").about("Download and install updates to rustup")) .subcommand( - App::new("uninstall") + Command::new("uninstall") .about("Uninstall rustup.") .arg(Arg::new("no-prompt").short('y')), ) - .subcommand(App::new("upgrade-data").about("Upgrade the internal data format.")), + .subcommand( + Command::new("upgrade-data").about("Upgrade the internal data format."), + ), ) .subcommand( - App::new("telemetry") + Command::new("telemetry") .about("rustup telemetry commands") .hide(true) .setting(AppSettings::DeriveDisplayOrder) - .subcommand(App::new("enable").about("Enable rustup telemetry")) - .subcommand(App::new("disable").about("Disable rustup telemetry")) - .subcommand(App::new("analyze").about("Analyze stored telemetry")), + .subcommand(Command::new("enable").about("Enable rustup telemetry")) + .subcommand(Command::new("disable").about("Disable rustup telemetry")) + .subcommand(Command::new("analyze").about("Analyze stored telemetry")), ) .subcommand( - App::new("set").about("Alter rustup settings").subcommand( - App::new("default-host") - .about("The triple used to identify toolchains when not specified") - .arg(Arg::new("host_triple").required(true)), - ), + Command::new("set") + .about("Alter rustup settings") + .subcommand( + Command::new("default-host") + .about("The triple used to identify toolchains when not specified") + .arg(Arg::new("host_triple").required(true)), + ), ) } diff --git a/clap_complete/Cargo.toml b/clap_complete/Cargo.toml index 850fd08be13..4f0fc141a8c 100644 --- a/clap_complete/Cargo.toml +++ b/clap_complete/Cargo.toml @@ -8,7 +8,7 @@ include = [ "LICENSE-*", "README.md" ] -description = "Generate shell completion scripts for your clap::App" +description = "Generate shell completion scripts for your clap::Command" repository = "https://github.com/clap-rs/clap/tree/master/clap_complete" documentation = "https://docs.rs/clap_complete" keywords = [ diff --git a/clap_complete/examples/bash_completion.rs b/clap_complete/examples/bash_completion.rs index 57c060ccefc..f243e77dcd6 100644 --- a/clap_complete/examples/bash_completion.rs +++ b/clap_complete/examples/bash_completion.rs @@ -1,11 +1,11 @@ -use clap::App; +use clap::Command; use clap_complete::{generate, shells::Bash}; use std::io; fn main() { - let mut app = App::new("myapp") - .subcommand(App::new("test").subcommand(App::new("config"))) - .subcommand(App::new("hello")); + let mut app = Command::new("myapp") + .subcommand(Command::new("test").subcommand(Command::new("config"))) + .subcommand(Command::new("hello")); generate(Bash, &mut app, "myapp", &mut io::stdout()); } diff --git a/clap_complete/examples/value_hints.rs b/clap_complete/examples/value_hints.rs index 5281f78b8bd..11ff8fbc72e 100644 --- a/clap_complete/examples/value_hints.rs +++ b/clap_complete/examples/value_hints.rs @@ -12,12 +12,12 @@ //! . ./value_hints.fish //! ./target/debug/examples/value_hints -- //! ``` -use clap::{App, Arg, ValueHint}; +use clap::{Arg, Command, ValueHint}; use clap_complete::{generate, Generator, Shell}; use std::io; -fn build_cli() -> App<'static> { - App::new("value_hints") +fn build_cli() -> Command<'static> { + Command::new("value_hints") // AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments .trailing_var_arg(true) .arg( @@ -92,7 +92,7 @@ fn build_cli() -> App<'static> { ) } -fn print_completions(gen: G, app: &mut App) { +fn print_completions(gen: G, app: &mut Command) { generate(gen, app, app.get_name().to_string(), &mut io::stdout()); } diff --git a/clap_complete/examples/value_hints_derive.rs b/clap_complete/examples/value_hints_derive.rs index 2cbcaadd1e6..4f454bf424b 100644 --- a/clap_complete/examples/value_hints_derive.rs +++ b/clap_complete/examples/value_hints_derive.rs @@ -12,7 +12,7 @@ //! . ./value_hints_derive.fish //! ./target/debug/examples/value_hints_derive -- //! ``` -use clap::{App, IntoApp, Parser, ValueHint}; +use clap::{Command, IntoApp, Parser, ValueHint}; use clap_complete::{generate, Generator, Shell}; use std::ffi::OsString; use std::io; @@ -21,7 +21,7 @@ use std::path::PathBuf; #[derive(Parser, Debug, PartialEq)] #[clap( name = "value_hints_derive", - // App::trailing_var_ar is required to use ValueHint::CommandWithArguments + // Command::trailing_var_ar is required to use ValueHint::CommandWithArguments trailing_var_arg = true, )] struct Opt { @@ -57,7 +57,7 @@ struct Opt { email: Option, } -fn print_completions(gen: G, app: &mut App) { +fn print_completions(gen: G, app: &mut Command) { generate(gen, app, app.get_name().to_string(), &mut io::stdout()); } diff --git a/clap_complete/src/generator/mod.rs b/clap_complete/src/generator/mod.rs index e5f3d239548..0300a875abd 100644 --- a/clap_complete/src/generator/mod.rs +++ b/clap_complete/src/generator/mod.rs @@ -8,7 +8,7 @@ use std::io::Error; use std::io::Write; use std::path::PathBuf; -use clap::App; +use clap::Command; /// Generator trait which can be used to write generators pub trait Generator { @@ -22,13 +22,13 @@ pub trait Generator { /// /// ``` /// # use std::io::Write; - /// # use clap::App; + /// # use clap::Command; /// use clap_complete::Generator; /// /// pub struct Fish; /// /// impl Generator for Fish { - /// # fn generate(&self, app: &App, buf: &mut dyn Write) {} + /// # fn generate(&self, app: &Command, buf: &mut dyn Write) {} /// fn file_name(&self, name: &str) -> String { /// format!("{}.fish", name) /// } @@ -36,7 +36,7 @@ pub trait Generator { /// ``` fn file_name(&self, name: &str) -> String; - /// Generates output out of [`clap::App`](App). + /// Generates output out of [`clap::Command`](Command). /// /// # Panics /// @@ -44,18 +44,18 @@ pub trait Generator { /// /// # Examples /// - /// The following example generator displays the [`clap::App`](App) + /// The following example generator displays the [`clap::Command`](Command) /// as if it is printed using [`std::println`]. /// /// ``` /// use std::{io::Write, fmt::write}; - /// use clap::App; + /// use clap::Command; /// use clap_complete::Generator; /// /// pub struct ClapDebug; /// /// impl Generator for ClapDebug { - /// fn generate(&self, app: &App, buf: &mut dyn Write) { + /// fn generate(&self, app: &Command, buf: &mut dyn Write) { /// write!(buf, "{}", app).unwrap(); /// } /// # fn file_name(&self, name: &str) -> String { @@ -63,7 +63,7 @@ pub trait Generator { /// # } /// } /// ``` - fn generate(&self, app: &App, buf: &mut dyn Write); + fn generate(&self, app: &Command, buf: &mut dyn Write); } /// Generate a completions file for a specified shell at compile-time. @@ -78,20 +78,20 @@ pub trait Generator { /// args. Real applications could be many multiple levels deep in subcommands, and have tens or /// potentially hundreds of arguments. /// -/// First, it helps if we separate out our `App` definition into a separate file. Whether you -/// do this as a function, or bare App definition is a matter of personal preference. +/// First, it helps if we separate out our `Command` definition into a separate file. Whether you +/// do this as a function, or bare Command definition is a matter of personal preference. /// /// ``` /// // src/cli.rs /// -/// use clap::{App, Arg}; +/// use clap::{Command, Arg}; /// -/// pub fn build_cli() -> App<'static> { -/// App::new("compl") +/// pub fn build_cli() -> Command<'static> { +/// Command::new("compl") /// .about("Tests completions") /// .arg(Arg::new("file") /// .help("some input file")) -/// .subcommand(App::new("test") +/// .subcommand(Command::new("test") /// .about("tests things") /// .arg(Arg::new("case") /// .long("case") @@ -166,7 +166,7 @@ pub trait Generator { /// to see the name of the files generated. pub fn generate_to( gen: G, - app: &mut clap::App, + app: &mut clap::Command, bin_name: S, out_dir: T, ) -> Result @@ -222,7 +222,7 @@ where /// ```shell /// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash /// ``` -pub fn generate(gen: G, app: &mut clap::App, bin_name: S, buf: &mut dyn Write) +pub fn generate(gen: G, app: &mut clap::Command, bin_name: S, buf: &mut dyn Write) where G: Generator, S: Into, @@ -231,7 +231,7 @@ where _generate::(gen, app, buf) } -fn _generate(gen: G, app: &mut clap::App, buf: &mut dyn Write) +fn _generate(gen: G, app: &mut clap::Command, buf: &mut dyn Write) where G: Generator, S: Into, diff --git a/clap_complete/src/generator/utils.rs b/clap_complete/src/generator/utils.rs index f707b18e8ab..8014b8fd4c6 100644 --- a/clap_complete/src/generator/utils.rs +++ b/clap_complete/src/generator/utils.rs @@ -1,12 +1,12 @@ //! Helpers for writing generators -use clap::{App, Arg}; +use clap::{Arg, Command}; /// Gets all subcommands including child subcommands in the form of `("name", "bin_name")`. /// /// Subcommand `rustup toolchain install` would be converted to /// `("install", "rustup toolchain install")`. -pub fn all_subcommands(app: &App) -> Vec<(String, String)> { +pub fn all_subcommands(app: &Command) -> Vec<(String, String)> { let mut subcmds: Vec<_> = subcommands(app); for sc_v in app.get_subcommands().map(all_subcommands) { @@ -16,13 +16,13 @@ pub fn all_subcommands(app: &App) -> Vec<(String, String)> { subcmds } -/// Finds the subcommand [`clap::App`] from the given [`clap::App`] with the given path. +/// Finds the subcommand [`clap::Command`] from the given [`clap::Command`] with the given path. /// /// **NOTE:** `path` should not contain the root `bin_name`. pub fn find_subcommand_with_path<'help, 'app>( - p: &'app App<'help>, + p: &'app Command<'help>, path: Vec<&str>, -) -> &'app App<'help> { +) -> &'app Command<'help> { let mut app = p; for sc in path { @@ -32,11 +32,11 @@ pub fn find_subcommand_with_path<'help, 'app>( app } -/// Gets subcommands of [`clap::App`] in the form of `("name", "bin_name")`. +/// Gets subcommands of [`clap::Command`] in the form of `("name", "bin_name")`. /// /// Subcommand `rustup toolchain install` would be converted to /// `("install", "rustup toolchain install")`. -pub fn subcommands(p: &App) -> Vec<(String, String)> { +pub fn subcommands(p: &Command) -> Vec<(String, String)> { debug!("subcommands: name={}", p.get_name()); debug!("subcommands: Has subcommands...{:?}", p.has_subcommands()); @@ -61,9 +61,9 @@ pub fn subcommands(p: &App) -> Vec<(String, String)> { subcmds } -/// Gets all the short options, their visible aliases and flags of a [`clap::App`]. +/// Gets all the short options, their visible aliases and flags of a [`clap::Command`]. /// Includes `h` and `V` depending on the [`clap::AppSettings`]. -pub fn shorts_and_visible_aliases(p: &App) -> Vec { +pub fn shorts_and_visible_aliases(p: &Command) -> Vec { debug!("shorts: name={}", p.get_name()); p.get_arguments() @@ -86,9 +86,9 @@ pub fn shorts_and_visible_aliases(p: &App) -> Vec { .collect() } -/// Gets all the long options, their visible aliases and flags of a [`clap::App`]. +/// Gets all the long options, their visible aliases and flags of a [`clap::Command`]. /// Includes `help` and `version` depending on the [`clap::AppSettings`]. -pub fn longs_and_visible_aliases(p: &App) -> Vec { +pub fn longs_and_visible_aliases(p: &Command) -> Vec { debug!("longs: name={}", p.get_name()); p.get_arguments() @@ -116,9 +116,9 @@ pub fn longs_and_visible_aliases(p: &App) -> Vec { .collect() } -/// Gets all the flags of a [`clap::App`](App). +/// Gets all the flags of a [`clap::Command`](Command). /// Includes `help` and `version` depending on the [`clap::AppSettings`]. -pub fn flags<'help>(p: &App<'help>) -> Vec> { +pub fn flags<'help>(p: &Command<'help>) -> Vec> { debug!("flags: name={}", p.get_name()); p.get_arguments() .filter(|a| !a.is_takes_value_set() && !a.is_positional()) @@ -132,10 +132,10 @@ mod tests { use clap::Arg; use pretty_assertions::assert_eq; - fn common_app() -> App<'static> { - App::new("myapp") + fn common_app() -> Command<'static> { + Command::new("myapp") .subcommand( - App::new("test").subcommand(App::new("config")).arg( + Command::new("test").subcommand(Command::new("config")).arg( Arg::new("file") .short('f') .short_alias('c') @@ -144,18 +144,18 @@ mod tests { .visible_alias("path"), ), ) - .subcommand(App::new("hello")) + .subcommand(Command::new("hello")) .bin_name("my-app") } - fn built() -> App<'static> { + fn built() -> Command<'static> { let mut app = common_app(); app._build_all(); app } - fn built_with_version() -> App<'static> { + fn built_with_version() -> Command<'static> { let mut app = common_app().version("3.0"); app._build_all(); diff --git a/clap_complete/src/lib.rs b/clap_complete/src/lib.rs index a349efd93e7..e3bcc392ee0 100644 --- a/clap_complete/src/lib.rs +++ b/clap_complete/src/lib.rs @@ -22,12 +22,12 @@ //! ## Example //! //! ```rust,no_run -//! use clap::{App, AppSettings, Arg, ValueHint}; +//! use clap::{Command, AppSettings, Arg, ValueHint}; //! use clap_complete::{generate, Generator, Shell}; //! use std::io; //! -//! fn build_cli() -> App<'static> { -//! App::new("example") +//! fn build_cli() -> Command<'static> { +//! Command::new("example") //! .arg(Arg::new("file") //! .help("some input file") //! .value_hint(ValueHint::AnyPath), @@ -39,7 +39,7 @@ //! ) //! } //! -//! fn print_completions(gen: G, app: &mut App) { +//! fn print_completions(gen: G, app: &mut Command) { //! generate(gen, app, app.get_name().to_string(), &mut io::stdout()); //! } //! diff --git a/clap_complete/src/shells/bash.rs b/clap_complete/src/shells/bash.rs index 3848437aeeb..ba619fa38e5 100644 --- a/clap_complete/src/shells/bash.rs +++ b/clap_complete/src/shells/bash.rs @@ -13,7 +13,7 @@ impl Generator for Bash { format!("{}.bash", name) } - fn generate(&self, app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &Command, buf: &mut dyn Write) { let bin_name = app .get_bin_name() .expect("crate::generate should have set the bin_name"); @@ -72,7 +72,7 @@ complete -F _{name} -o bashdefault -o default {name} } } -fn all_subcommands(app: &App) -> String { +fn all_subcommands(app: &Command) -> String { debug!("all_subcommands"); let mut subcmds = vec![String::new()]; @@ -97,7 +97,7 @@ fn all_subcommands(app: &App) -> String { subcmds.join("\n ") } -fn subcommand_details(app: &App) -> String { +fn subcommand_details(app: &Command) -> String { debug!("subcommand_details"); let mut subcmd_dets = vec![String::new()]; @@ -134,7 +134,7 @@ fn subcommand_details(app: &App) -> String { subcmd_dets.join("\n ") } -fn option_details_for_path(app: &App, path: &str) -> String { +fn option_details_for_path(app: &Command, path: &str) -> String { debug!("option_details_for_path: path={}", path); let p = utils::find_subcommand_with_path(app, path.split("__").skip(1).collect()); @@ -187,7 +187,7 @@ fn vals_for(o: &Arg) -> String { } } -fn all_options_for_path(app: &App, path: &str) -> String { +fn all_options_for_path(app: &Command, path: &str) -> String { debug!("all_options_for_path: path={}", path); let p = utils::find_subcommand_with_path(app, path.split("__").skip(1).collect()); diff --git a/clap_complete/src/shells/elvish.rs b/clap_complete/src/shells/elvish.rs index 7ad4b4b4830..e920fad9aca 100644 --- a/clap_complete/src/shells/elvish.rs +++ b/clap_complete/src/shells/elvish.rs @@ -14,7 +14,7 @@ impl Generator for Elvish { format!("{}.elv", name) } - fn generate(&self, app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &Command, buf: &mut dyn Write) { let bin_name = app .get_bin_name() .expect("crate::generate should have set the bin_name"); @@ -67,7 +67,7 @@ fn get_tooltip(help: Option<&str>, data: T) -> String { } fn generate_inner<'help>( - p: &App<'help>, + p: &Command<'help>, previous_command_name: &str, names: &mut Vec<&'help str>, ) -> String { diff --git a/clap_complete/src/shells/fish.rs b/clap_complete/src/shells/fish.rs index 3327dbc10d7..c10f49aeec0 100644 --- a/clap_complete/src/shells/fish.rs +++ b/clap_complete/src/shells/fish.rs @@ -15,7 +15,7 @@ impl Generator for Fish { format!("{}.fish", name) } - fn generate(&self, app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &Command, buf: &mut dyn Write) { let bin_name = app .get_bin_name() .expect("crate::generate should have set the bin_name"); @@ -31,7 +31,12 @@ fn escape_string(string: &str) -> String { string.replace('\\', "\\\\").replace('\'', "\\'") } -fn gen_fish_inner(root_command: &str, parent_commands: &[&str], app: &App, buffer: &mut String) { +fn gen_fish_inner( + root_command: &str, + parent_commands: &[&str], + app: &Command, + buffer: &mut String, +) { debug!("gen_fish_inner"); // example : // diff --git a/clap_complete/src/shells/powershell.rs b/clap_complete/src/shells/powershell.rs index 77a007e41e9..eddabdc9a4b 100644 --- a/clap_complete/src/shells/powershell.rs +++ b/clap_complete/src/shells/powershell.rs @@ -14,7 +14,7 @@ impl Generator for PowerShell { format!("_{}.ps1", name) } - fn generate(&self, app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &Command, buf: &mut dyn Write) { let bin_name = app .get_bin_name() .expect("crate::generate should have set the bin_name"); @@ -72,7 +72,7 @@ fn get_tooltip(help: Option<&str>, data: T) -> String { } fn generate_inner<'help>( - p: &App<'help>, + p: &Command<'help>, previous_command_name: &str, names: &mut Vec<&'help str>, ) -> String { diff --git a/clap_complete/src/shells/shell.rs b/clap_complete/src/shells/shell.rs index 09ad4965592..72ade7bfc15 100644 --- a/clap_complete/src/shells/shell.rs +++ b/clap_complete/src/shells/shell.rs @@ -87,7 +87,7 @@ impl Generator for Shell { } } - fn generate(&self, app: &clap::App, buf: &mut dyn std::io::Write) { + fn generate(&self, app: &clap::Command, buf: &mut dyn std::io::Write) { match self { Shell::Bash => shells::Bash.generate(app, buf), Shell::Elvish => shells::Elvish.generate(app, buf), diff --git a/clap_complete/src/shells/zsh.rs b/clap_complete/src/shells/zsh.rs index e5887134868..eb7a23f3e96 100644 --- a/clap_complete/src/shells/zsh.rs +++ b/clap_complete/src/shells/zsh.rs @@ -14,7 +14,7 @@ impl Generator for Zsh { format!("_{}", name) } - fn generate(&self, app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &Command, buf: &mut dyn Write) { let bin_name = app .get_bin_name() .expect("crate::generate should have set the bin_name"); @@ -82,7 +82,7 @@ _{name} \"$@\" // ) // _describe -t commands 'rustup commands' commands "$@" // -fn subcommand_details(p: &App) -> String { +fn subcommand_details(p: &Command) -> String { debug!("subcommand_details"); let bin_name = p @@ -142,12 +142,12 @@ _{bin_name_underscore}_commands() {{ // A snippet from rustup: // 'show:Show the active and installed toolchains' // 'update:Update Rust toolchains' -fn subcommands_of(p: &App) -> String { +fn subcommands_of(p: &Command) -> String { debug!("subcommands_of"); let mut segments = vec![]; - fn add_subcommands(subcommand: &App, name: &str, ret: &mut Vec) { + fn add_subcommands(subcommand: &Command, name: &str, ret: &mut Vec) { debug!("add_subcommands"); let text = format!( @@ -212,7 +212,7 @@ fn subcommands_of(p: &App) -> String { // [name_hyphen] = The full space delineated bin_name, but replace spaces with hyphens // [repeat] = From the same recursive calls, but for all subcommands // [subcommand_args] = The same as zsh::get_args_of -fn get_subcommands_of(parent: &App) -> String { +fn get_subcommands_of(parent: &Command) -> String { debug!( "get_subcommands_of: Has subcommands...{:?}", parent.has_subcommands() @@ -276,11 +276,14 @@ esac", ) } -// Get the App for a given subcommand tree. +// Get the Command for a given subcommand tree. // -// Given the bin_name "a b c" and the App for "a" this returns the "c" App. -// Given the bin_name "a b c" and the App for "b" this returns the "c" App. -fn parser_of<'help, 'app>(parent: &'app App<'help>, bin_name: &str) -> Option<&'app App<'help>> { +// Given the bin_name "a b c" and the Command for "a" this returns the "c" Command. +// Given the bin_name "a b c" and the Command for "b" this returns the "c" Command. +fn parser_of<'help, 'app>( + parent: &'app Command<'help>, + bin_name: &str, +) -> Option<&'app Command<'help>> { debug!("parser_of: p={}, bin_name={}", parent.get_name(), bin_name); if bin_name == parent.get_bin_name().unwrap_or(&String::new()) { @@ -316,7 +319,7 @@ fn parser_of<'help, 'app>(parent: &'app App<'help>, bin_name: &str) -> Option<&' // -C: modify the $context internal variable // -s: Allow stacking of short args (i.e. -a -b -c => -abc) // -S: Do not complete anything after '--' and treat those as argument values -fn get_args_of(parent: &App, p_global: Option<&App>) -> String { +fn get_args_of(parent: &Command, p_global: Option<&Command>) -> String { debug!("get_args_of"); let mut segments = vec![String::from("_arguments \"${_arguments_options[@]}\" \\")]; @@ -436,7 +439,7 @@ fn escape_value(string: &str) -> String { .replace(' ', "\\ ") } -fn write_opts_of(p: &App, p_global: Option<&App>) -> String { +fn write_opts_of(p: &Command, p_global: Option<&Command>) -> String { debug!("write_opts_of"); let mut ret = vec![]; @@ -501,7 +504,7 @@ fn write_opts_of(p: &App, p_global: Option<&App>) -> String { ret.join("\n") } -fn arg_conflicts(app: &App, arg: &Arg, app_global: Option<&App>) -> String { +fn arg_conflicts(app: &Command, arg: &Arg, app_global: Option<&Command>) -> String { fn push_conflicts(conflicts: &[&Arg], res: &mut Vec) { for conflict in conflicts { if let Some(s) = conflict.get_short() { @@ -539,7 +542,7 @@ fn arg_conflicts(app: &App, arg: &Arg, app_global: Option<&App>) -> String { format!("({})", res.join(" ")) } -fn write_flags_of(p: &App, p_global: Option<&App>) -> String { +fn write_flags_of(p: &Command, p_global: Option<&Command>) -> String { debug!("write_flags_of;"); let mut ret = vec![]; @@ -620,7 +623,7 @@ fn write_flags_of(p: &App, p_global: Option<&App>) -> String { ret.join("\n") } -fn write_positionals_of(p: &App) -> String { +fn write_positionals_of(p: &Command) -> String { debug!("write_positionals_of;"); let mut ret = vec![]; diff --git a/clap_complete/tests/completions/bash.rs b/clap_complete/tests/completions/bash.rs index eff83f480df..8f3812a7159 100644 --- a/clap_complete/tests/completions/bash.rs +++ b/clap_complete/tests/completions/bash.rs @@ -1,11 +1,11 @@ use super::*; -fn build_app() -> App<'static> { +fn build_app() -> Command<'static> { build_app_with_name("myapp") } -fn build_app_with_name(s: &'static str) -> App<'static> { - App::new(s) +fn build_app_with_name(s: &'static str) -> Command<'static> { + Command::new(s) .version("3.0") .propagate_version(true) .about("Tests completions") @@ -16,7 +16,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { ) .arg(Arg::new("choice").possible_values(["first", "second"])) .subcommand( - App::new("test").about("tests things").arg( + Command::new("test").about("tests things").arg( Arg::new("case") .long("case") .takes_value(true) @@ -115,17 +115,17 @@ fn bash_with_special_commands() { common(Bash, &mut app, "my_app", BASH_SPECIAL_CMDS); } -fn build_app_special_commands() -> App<'static> { +fn build_app_special_commands() -> Command<'static> { build_app_with_name("my_app") .subcommand( - App::new("some_cmd").about("tests other things").arg( + Command::new("some_cmd").about("tests other things").arg( Arg::new("config") .long("--config") .takes_value(true) .help("the other case to test"), ), ) - .subcommand(App::new("some-cmd-with-hyphens").alias("hyphen")) + .subcommand(Command::new("some-cmd-with-hyphens").alias("hyphen")) } static BASH_SPECIAL_CMDS: &str = r#"_my_app() { @@ -250,8 +250,8 @@ fn bash_with_aliases() { common(Bash, &mut app, "cmd", BASH_ALIASES); } -fn build_app_with_aliases() -> App<'static> { - App::new("cmd") +fn build_app_with_aliases() -> Command<'static> { + Command::new("cmd") .version("3.0") .about("testing bash completions") .arg( diff --git a/clap_complete/tests/completions/elvish.rs b/clap_complete/tests/completions/elvish.rs index 0926a1606f8..7cd9624344d 100644 --- a/clap_complete/tests/completions/elvish.rs +++ b/clap_complete/tests/completions/elvish.rs @@ -1,11 +1,11 @@ use super::*; -fn build_app() -> App<'static> { +fn build_app() -> Command<'static> { build_app_with_name("myapp") } -fn build_app_with_name(s: &'static str) -> App<'static> { - App::new(s) +fn build_app_with_name(s: &'static str) -> Command<'static> { + Command::new(s) .version("3.0") .propagate_version(true) .about("Tests completions") @@ -15,7 +15,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { .help("some input file"), ) .subcommand( - App::new("test").about("tests things").arg( + Command::new("test").about("tests things").arg( Arg::new("case") .long("case") .takes_value(true) @@ -77,17 +77,17 @@ fn elvish_with_special_commands() { common(Elvish, &mut app, "my_app", ELVISH_SPECIAL_CMDS); } -fn build_app_special_commands() -> App<'static> { +fn build_app_special_commands() -> Command<'static> { build_app_with_name("my_app") .subcommand( - App::new("some_cmd").about("tests other things").arg( + Command::new("some_cmd").about("tests other things").arg( Arg::new("config") .long("--config") .takes_value(true) .help("the other case to test"), ), ) - .subcommand(App::new("some-cmd-with-hyphens").alias("hyphen")) + .subcommand(Command::new("some-cmd-with-hyphens").alias("hyphen")) } static ELVISH_SPECIAL_CMDS: &str = r#" @@ -152,8 +152,8 @@ fn elvish_with_aliases() { common(Elvish, &mut app, "cmd", ELVISH_ALIASES); } -fn build_app_with_aliases() -> App<'static> { - App::new("cmd") +fn build_app_with_aliases() -> Command<'static> { + Command::new("cmd") .version("3.0") .about("testing bash completions") .arg( diff --git a/clap_complete/tests/completions/fish.rs b/clap_complete/tests/completions/fish.rs index beb0ae39c6e..5d893dd24f5 100644 --- a/clap_complete/tests/completions/fish.rs +++ b/clap_complete/tests/completions/fish.rs @@ -2,12 +2,12 @@ use clap::PossibleValue; use super::*; -fn build_app() -> App<'static> { +fn build_app() -> Command<'static> { build_app_with_name("myapp") } -fn build_app_with_name(s: &'static str) -> App<'static> { - App::new(s) +fn build_app_with_name(s: &'static str) -> Command<'static> { + Command::new(s) .version("3.0") .propagate_version(true) .about("Tests completions") @@ -17,7 +17,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { .help("some input file"), ) .subcommand( - App::new("test").about("tests things").arg( + Command::new("test").about("tests things").arg( Arg::new("case") .long("case") .takes_value(true) @@ -47,17 +47,17 @@ fn fish_with_special_commands() { common(Fish, &mut app, "my_app", FISH_SPECIAL_CMDS); } -fn build_app_special_commands() -> App<'static> { +fn build_app_special_commands() -> Command<'static> { build_app_with_name("my_app") .subcommand( - App::new("some_cmd").about("tests other things").arg( + Command::new("some_cmd").about("tests other things").arg( Arg::new("config") .long("--config") .takes_value(true) .help("the other case to test"), ), ) - .subcommand(App::new("some-cmd-with-hyphens").alias("hyphen")) + .subcommand(Command::new("some-cmd-with-hyphens").alias("hyphen")) } static FISH_SPECIAL_CMDS: &str = r#"complete -c my_app -n "__fish_use_subcommand" -s h -l help -d 'Print help information' @@ -82,8 +82,8 @@ fn fish_with_special_help() { common(Fish, &mut app, "my_app", FISH_SPECIAL_HELP); } -fn build_app_special_help() -> App<'static> { - App::new("my_app") +fn build_app_special_help() -> Command<'static> { + Command::new("my_app") .version("3.0") .arg( Arg::new("single-quotes") @@ -129,8 +129,8 @@ fn fish_with_aliases() { common(Fish, &mut app, "cmd", FISH_ALIASES); } -fn build_app_with_aliases() -> App<'static> { - App::new("cmd") +fn build_app_with_aliases() -> Command<'static> { + Command::new("cmd") .version("3.0") .about("testing bash completions") .arg( @@ -165,12 +165,12 @@ fn fish_with_sub_subcommands() { common(Fish, &mut app, "my_app", FISH_SUB_SUBCMDS); } -fn build_app_sub_subcommands() -> App<'static> { +fn build_app_sub_subcommands() -> Command<'static> { build_app_with_name("my_app").subcommand( - App::new("some_cmd") + Command::new("some_cmd") .about("top level subcommand") .subcommand( - App::new("sub_cmd").about("sub-subcommand").arg( + Command::new("sub_cmd").about("sub-subcommand").arg( Arg::new("config") .long("--config") .takes_value(true) diff --git a/clap_complete/tests/completions/mod.rs b/clap_complete/tests/completions/mod.rs index f3b947a8938..257436eba9c 100644 --- a/clap_complete/tests/completions/mod.rs +++ b/clap_complete/tests/completions/mod.rs @@ -1,4 +1,4 @@ -use clap::{App, Arg, ValueHint}; +use clap::{Arg, Command, ValueHint}; use clap_complete::{generate, shells::*, Generator}; use std::fmt; @@ -23,7 +23,7 @@ macro_rules! assert_eq { }; } -pub fn common(gen: G, app: &mut App, name: &str, fixture: &str) { +pub fn common(gen: G, app: &mut Command, name: &str, fixture: &str) { let mut buf = vec![]; generate(gen, app, name, &mut buf); let string = String::from_utf8(buf).unwrap(); diff --git a/clap_complete/tests/completions/powershell.rs b/clap_complete/tests/completions/powershell.rs index 914ba89def3..347933ef1be 100644 --- a/clap_complete/tests/completions/powershell.rs +++ b/clap_complete/tests/completions/powershell.rs @@ -1,11 +1,11 @@ use super::*; -fn build_app() -> App<'static> { +fn build_app() -> Command<'static> { build_app_with_name("myapp") } -fn build_app_with_name(s: &'static str) -> App<'static> { - App::new(s) +fn build_app_with_name(s: &'static str) -> Command<'static> { + Command::new(s) .version("3.0") .propagate_version(true) .about("Tests completions") @@ -23,7 +23,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { .visible_alias("conf"), ) .subcommand( - App::new("test").about("tests things").arg( + Command::new("test").about("tests things").arg( Arg::new("case") .long("case") .takes_value(true) @@ -97,17 +97,17 @@ fn powershell_with_special_commands() { common(PowerShell, &mut app, "my_app", POWERSHELL_SPECIAL_CMDS); } -fn build_app_special_commands() -> App<'static> { +fn build_app_special_commands() -> Command<'static> { build_app_with_name("my_app") .subcommand( - App::new("some_cmd").about("tests other things").arg( + Command::new("some_cmd").about("tests other things").arg( Arg::new("config") .long("--config") .takes_value(true) .help("the other case to test"), ), ) - .subcommand(App::new("some-cmd-with-hyphens").alias("hyphen")) + .subcommand(Command::new("some-cmd-with-hyphens").alias("hyphen")) } static POWERSHELL_SPECIAL_CMDS: &str = r#" @@ -186,8 +186,8 @@ fn powershell_with_aliases() { common(PowerShell, &mut app, "cmd", POWERSHELL_ALIASES); } -fn build_app_with_aliases() -> App<'static> { - App::new("cmd") +fn build_app_with_aliases() -> Command<'static> { + Command::new("cmd") .version("3.0") .about("testing bash completions") .arg( diff --git a/clap_complete/tests/completions/zsh.rs b/clap_complete/tests/completions/zsh.rs index 73dbc43bcc8..35c9028f42f 100644 --- a/clap_complete/tests/completions/zsh.rs +++ b/clap_complete/tests/completions/zsh.rs @@ -1,11 +1,11 @@ use super::*; -fn build_app() -> App<'static> { +fn build_app() -> Command<'static> { build_app_with_name("myapp") } -fn build_app_with_name(s: &'static str) -> App<'static> { - App::new(s) +fn build_app_with_name(s: &'static str) -> Command<'static> { + Command::new(s) .version("3.0") .propagate_version(true) .about("Test test's completions") @@ -15,7 +15,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { .help("some input's file"), ) .subcommand( - App::new("test").about("test test's things").arg( + Command::new("test").about("test test's things").arg( Arg::new("case") .long("case") .takes_value(true) @@ -108,19 +108,19 @@ fn zsh_with_special_commands() { common(Zsh, &mut app, "my_app", ZSH_SPECIAL_CMDS); } -fn build_app_special_commands() -> App<'static> { +fn build_app_special_commands() -> Command<'static> { build_app_with_name("my_app") .subcommand( - App::new("some_cmd").about("tests other things").arg( + Command::new("some_cmd").about("tests other things").arg( Arg::new("config") .long("--config") .takes_value(true) .help("the other case to test"), ), ) - .subcommand(App::new("some-cmd-with-hypens").alias("hyphen")) + .subcommand(Command::new("some-cmd-with-hypens").alias("hyphen")) .subcommand( - App::new("some_cmd_with_special_characters") + Command::new("some_cmd_with_special_characters") .about("This 'is' a \"special\" [character] string \\"), ) } @@ -246,8 +246,8 @@ fn zsh_with_special_help() { common(Zsh, &mut app, "my_app", ZSH_SPECIAL_HELP); } -fn build_app_special_help() -> App<'static> { - App::new("my_app") +fn build_app_special_help() -> Command<'static> { + Command::new("my_app") .version("3.0") .arg( Arg::new("single-quotes") @@ -322,10 +322,10 @@ fn zsh_with_nested_subcommands() { common(Zsh, &mut app, "my_app", ZSH_NESTED_SUBCOMMANDS); } -fn build_app_nested_subcommands() -> App<'static> { - App::new("first") +fn build_app_nested_subcommands() -> Command<'static> { + Command::new("first") .version("3.0") - .subcommand(App::new("second").subcommand(App::new("third"))) + .subcommand(Command::new("second").subcommand(Command::new("third"))) } static ZSH_NESTED_SUBCOMMANDS: &str = r#"#compdef my_app @@ -442,8 +442,8 @@ fn zsh_with_aliases() { common(Zsh, &mut app, "cmd", ZSH_ALIASES); } -fn build_app_with_aliases() -> App<'static> { - App::new("cmd") +fn build_app_with_aliases() -> Command<'static> { + Command::new("cmd") .version("3.0") .about("testing bash completions") .arg( @@ -514,8 +514,8 @@ fn zsh_with_files_and_dirs() { common(Zsh, &mut app, "my_app", ZSH_PATHS); } -fn build_app_with_files_and_dirs() -> App<'static> { - App::new("my_app") +fn build_app_with_files_and_dirs() -> Command<'static> { + Command::new("my_app") .version("3.0") .about("testing zsh completions") .arg( diff --git a/clap_complete/tests/generate_completions.rs b/clap_complete/tests/generate_completions.rs index cfafe477ce5..0b9cc706781 100644 --- a/clap_complete/tests/generate_completions.rs +++ b/clap_complete/tests/generate_completions.rs @@ -1,16 +1,16 @@ use std::io; -use clap::{App, Arg}; +use clap::{Arg, Command}; use clap_complete::{generate, shells::*}; #[test] fn generate_completions() { - let mut app = App::new("test_app") + let mut app = Command::new("test_app") .arg(Arg::new("config").short('c').global(true)) .arg(Arg::new("v").short('v').conflicts_with("config")) .subcommand( - App::new("test") + Command::new("test") .about("Subcommand") .arg(Arg::new("debug").short('d')), ); diff --git a/clap_complete/tests/value_hints.rs b/clap_complete/tests/value_hints.rs index 60b586b15e8..a07a948a811 100644 --- a/clap_complete/tests/value_hints.rs +++ b/clap_complete/tests/value_hints.rs @@ -1,12 +1,12 @@ mod completions; -use clap::{App, Arg, ValueHint}; +use clap::{Arg, Command, ValueHint}; use clap_complete::shells::*; use completions::common; -pub fn build_app_with_value_hints() -> App<'static> { - App::new("my_app") +pub fn build_app_with_value_hints() -> Command<'static> { + Command::new("my_app") .trailing_var_arg(true) .arg( Arg::new("choice") diff --git a/clap_complete_fig/examples/fig_completion.rs b/clap_complete_fig/examples/fig_completion.rs index d3907b74e5b..8e59d6e7980 100644 --- a/clap_complete_fig/examples/fig_completion.rs +++ b/clap_complete_fig/examples/fig_completion.rs @@ -1,12 +1,12 @@ -use clap::App; +use clap::Command; use clap_complete::generate; use clap_complete_fig::Fig; use std::io; fn main() { - let mut app = App::new("myapp") - .subcommand(App::new("test").subcommand(App::new("config"))) - .subcommand(App::new("hello")); + let mut app = Command::new("myapp") + .subcommand(Command::new("test").subcommand(Command::new("config"))) + .subcommand(Command::new("hello")); generate(Fig, &mut app, "myapp", &mut io::stdout()); } diff --git a/clap_complete_fig/src/fig.rs b/clap_complete_fig/src/fig.rs index 95c3ef467f5..3542a7023b6 100644 --- a/clap_complete_fig/src/fig.rs +++ b/clap_complete_fig/src/fig.rs @@ -13,7 +13,7 @@ impl Generator for Fig { format!("{}.ts", name) } - fn generate(&self, app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &Command, buf: &mut dyn Write) { let command = app.get_bin_name().unwrap(); let mut buffer = String::new(); @@ -45,7 +45,7 @@ fn gen_fig_inner( root_command: &str, parent_commands: &[&str], indent: usize, - app: &App, + app: &Command, buffer: &mut String, ) { if app.has_subcommands() { @@ -105,7 +105,7 @@ fn gen_fig_inner( }; } -fn gen_options(app: &App, indent: usize) -> String { +fn gen_options(app: &Command, indent: usize) -> String { let mut buffer = String::new(); buffer.push_str(&format!("{:indent$}options: [\n", "", indent = indent)); diff --git a/clap_complete_fig/tests/completions/fig.rs b/clap_complete_fig/tests/completions/fig.rs index 4e7860ea425..58d04678512 100644 --- a/clap_complete_fig/tests/completions/fig.rs +++ b/clap_complete_fig/tests/completions/fig.rs @@ -1,12 +1,12 @@ use super::*; use crate::Fig; -fn build_app() -> App<'static> { +fn build_app() -> Command<'static> { build_app_with_name("myapp") } -fn build_app_with_name(s: &'static str) -> App<'static> { - App::new(s) +fn build_app_with_name(s: &'static str) -> Command<'static> { + Command::new(s) .version("3.0") .propagate_version(true) .about("Tests completions") @@ -16,7 +16,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { .help("some input file"), ) .subcommand( - App::new("test").about("tests things").arg( + Command::new("test").about("tests things").arg( Arg::new("case") .long("case") .takes_value(true) @@ -94,17 +94,17 @@ fn fig_with_special_commands() { common(Fig, &mut app, "my_app", FIG_SPECIAL_CMDS); } -fn build_app_special_commands() -> App<'static> { +fn build_app_special_commands() -> Command<'static> { build_app_with_name("my_app") .subcommand( - App::new("some_cmd").about("tests other things").arg( + Command::new("some_cmd").about("tests other things").arg( Arg::new("config") .long("--config") .takes_value(true) .help("the other case to test"), ), ) - .subcommand(App::new("some-cmd-with-hyphens").alias("hyphen")) + .subcommand(Command::new("some-cmd-with-hyphens").alias("hyphen")) } static FIG_SPECIAL_CMDS: &str = r#"const completion: Fig.Spec = { @@ -205,8 +205,8 @@ fn fig_with_special_help() { common(Fig, &mut app, "my_app", FIG_SPECIAL_HELP); } -fn build_app_special_help() -> App<'static> { - App::new("my_app") +fn build_app_special_help() -> Command<'static> { + Command::new("my_app") .version("3.0") .arg( Arg::new("single-quotes") @@ -284,8 +284,8 @@ fn fig_with_aliases() { common(Fig, &mut app, "cmd", FIG_ALIASES); } -fn build_app_with_aliases() -> App<'static> { - App::new("cmd") +fn build_app_with_aliases() -> Command<'static> { + Command::new("cmd") .version("3.0") .about("testing bash completions") .arg( @@ -348,12 +348,12 @@ fn fig_with_sub_subcommands() { common(Fig, &mut app, "my_app", FIG_SUB_SUBCMDS); } -fn build_app_sub_subcommands() -> App<'static> { +fn build_app_sub_subcommands() -> Command<'static> { build_app_with_name("my_app").subcommand( - App::new("some_cmd") + Command::new("some_cmd") .about("top level subcommand") .subcommand( - App::new("sub_cmd").about("sub-subcommand").arg( + Command::new("sub_cmd").about("sub-subcommand").arg( Arg::new("config") .long("--config") .takes_value(true) diff --git a/clap_complete_fig/tests/completions/mod.rs b/clap_complete_fig/tests/completions/mod.rs index f2923d8c2ff..bb51b42c143 100644 --- a/clap_complete_fig/tests/completions/mod.rs +++ b/clap_complete_fig/tests/completions/mod.rs @@ -1,4 +1,4 @@ -use clap::{App, Arg, ValueHint}; +use clap::{Arg, Command, ValueHint}; use clap_complete::{generate, Generator}; use std::fmt; @@ -19,7 +19,7 @@ macro_rules! assert_eq { }; } -pub fn common(gen: G, app: &mut App, name: &str, fixture: &str) { +pub fn common(gen: G, app: &mut Command, name: &str, fixture: &str) { let mut buf = vec![]; generate(gen, app, name, &mut buf); let string = String::from_utf8(buf).unwrap(); diff --git a/clap_complete_fig/tests/generate_completions.rs b/clap_complete_fig/tests/generate_completions.rs index 3e6d9cc2f1d..405b94354ad 100644 --- a/clap_complete_fig/tests/generate_completions.rs +++ b/clap_complete_fig/tests/generate_completions.rs @@ -1,15 +1,15 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; use clap_complete::generate; use clap_complete_fig::Fig; use std::io; #[test] fn generate_completions() { - let mut app = App::new("test_app") + let mut app = Command::new("test_app") .arg(Arg::new("config").short('c').global(true)) .arg(Arg::new("v").short('v').conflicts_with("config")) .subcommand( - App::new("test") + Command::new("test") .about("Subcommand") .arg(Arg::new("debug").short('d')), ); diff --git a/clap_complete_fig/tests/value_hints.rs b/clap_complete_fig/tests/value_hints.rs index 15fa4e235aa..ea71420eee4 100644 --- a/clap_complete_fig/tests/value_hints.rs +++ b/clap_complete_fig/tests/value_hints.rs @@ -1,11 +1,11 @@ -use clap::{App, Arg, ValueHint}; +use clap::{Arg, Command, ValueHint}; use clap_complete_fig::Fig; use completions::common; mod completions; -pub fn build_app_with_value_hints() -> App<'static> { - App::new("my_app") +pub fn build_app_with_value_hints() -> Command<'static> { + Command::new("my_app") .disable_version_flag(true) .trailing_var_arg(true) .arg( diff --git a/clap_derive/src/derives/args.rs b/clap_derive/src/derives/args.rs index 3bdd32010ee..738ac56180d 100644 --- a/clap_derive/src/derives/args.rs +++ b/clap_derive/src/derives/args.rs @@ -87,10 +87,10 @@ pub fn gen_for_struct( )] #[deny(clippy::correctness)] impl #impl_generics clap::Args for #struct_name #ty_generics #where_clause { - fn augment_args<'b>(#app_var: clap::App<'b>) -> clap::App<'b> { + fn augment_args<'b>(#app_var: clap::Command<'b>) -> clap::Command<'b> { #augmentation } - fn augment_args_for_update<'b>(#app_var: clap::App<'b>) -> clap::App<'b> { + fn augment_args_for_update<'b>(#app_var: clap::Command<'b>) -> clap::Command<'b> { #augmentation_update } } diff --git a/clap_derive/src/derives/into_app.rs b/clap_derive/src/derives/into_app.rs index 3df12f5b39e..cae57ea15a2 100644 --- a/clap_derive/src/derives/into_app.rs +++ b/clap_derive/src/derives/into_app.rs @@ -57,13 +57,13 @@ pub fn gen_for_struct( )] #[deny(clippy::correctness)] impl #impl_generics clap::IntoApp for #struct_name #ty_generics #where_clause { - fn into_app<'b>() -> clap::App<'b> { - let #app_var = clap::App::new(#name); + fn into_app<'b>() -> clap::Command<'b> { + let #app_var = clap::Command::new(#name); ::augment_args(#app_var) } - fn into_app_for_update<'b>() -> clap::App<'b> { - let #app_var = clap::App::new(#name); + fn into_app_for_update<'b>() -> clap::Command<'b> { + let #app_var = clap::Command::new(#name); ::augment_args_for_update(#app_var) } } @@ -102,15 +102,15 @@ pub fn gen_for_enum(enum_name: &Ident, generics: &Generics, attrs: &[Attribute]) )] #[deny(clippy::correctness)] impl #impl_generics clap::IntoApp for #enum_name #ty_generics #where_clause { - fn into_app<'b>() -> clap::App<'b> { + fn into_app<'b>() -> clap::Command<'b> { #[allow(deprecated)] - let #app_var = clap::App::new(#name) + let #app_var = clap::Command::new(#name) .setting(clap::AppSettings::SubcommandRequiredElseHelp); ::augment_subcommands(#app_var) } - fn into_app_for_update<'b>() -> clap::App<'b> { - let #app_var = clap::App::new(#name); + fn into_app_for_update<'b>() -> clap::Command<'b> { + let #app_var = clap::Command::new(#name); ::augment_subcommands_for_update(#app_var) } } diff --git a/clap_derive/src/derives/subcommand.rs b/clap_derive/src/derives/subcommand.rs index c6c7738f5c1..2ec64cdb7a6 100644 --- a/clap_derive/src/derives/subcommand.rs +++ b/clap_derive/src/derives/subcommand.rs @@ -75,10 +75,10 @@ pub fn gen_for_enum( )] #[deny(clippy::correctness)] impl #impl_generics clap::Subcommand for #enum_name #ty_generics #where_clause { - fn augment_subcommands <'b>(__clap_app: clap::App<'b>) -> clap::App<'b> { + fn augment_subcommands <'b>(__clap_app: clap::Command<'b>) -> clap::Command<'b> { #augmentation } - fn augment_subcommands_for_update <'b>(__clap_app: clap::App<'b>) -> clap::App<'b> { + fn augment_subcommands_for_update <'b>(__clap_app: clap::Command<'b>) -> clap::Command<'b> { #augmentation_update } fn has_subcommand(__clap_name: &str) -> bool { @@ -245,7 +245,7 @@ fn gen_augment( let final_from_attrs = attrs.final_top_level_methods(); let subcommand = quote! { let #app_var = #app_var.subcommand({ - let #subcommand_var = clap::App::new(#name); + let #subcommand_var = clap::Command::new(#name); let #subcommand_var = #subcommand_var #initial_app_methods; let #subcommand_var = #arg_block; #[allow(deprecated)] @@ -304,7 +304,7 @@ fn gen_augment( let name = attrs.cased_name(); let subcommand = quote! { let #app_var = #app_var.subcommand({ - let #subcommand_var = clap::App::new(#name); + let #subcommand_var = clap::Command::new(#name); #sub_augment }); }; diff --git a/clap_derive/src/dummies.rs b/clap_derive/src/dummies.rs index 291aba99d82..b827f0e8fcd 100644 --- a/clap_derive/src/dummies.rs +++ b/clap_derive/src/dummies.rs @@ -19,10 +19,10 @@ pub fn parser_enum(name: &Ident) { pub fn into_app(name: &Ident) { append_dummy(quote! { impl clap::IntoApp for #name { - fn into_app<'b>() -> clap::App<'b> { + fn into_app<'b>() -> clap::Command<'b> { unimplemented!() } - fn into_app_for_update<'b>() -> clap::App<'b> { + fn into_app_for_update<'b>() -> clap::Command<'b> { unimplemented!() } } @@ -46,10 +46,10 @@ pub fn subcommand(name: &Ident) { from_arg_matches(name); append_dummy(quote! { impl clap::Subcommand for #name { - fn augment_subcommands(_app: clap::App<'_>) -> clap::App<'_> { + fn augment_subcommands(_app: clap::Command<'_>) -> clap::Command<'_> { unimplemented!() } - fn augment_subcommands_for_update(_app: clap::App<'_>) -> clap::App<'_> { + fn augment_subcommands_for_update(_app: clap::Command<'_>) -> clap::Command<'_> { unimplemented!() } fn has_subcommand(name: &str) -> bool { @@ -63,10 +63,10 @@ pub fn args(name: &Ident) { from_arg_matches(name); append_dummy(quote! { impl clap::Args for #name { - fn augment_args(_app: clap::App<'_>) -> clap::App<'_> { + fn augment_args(_app: clap::Command<'_>) -> clap::Command<'_> { unimplemented!() } - fn augment_args_for_update(_app: clap::App<'_>) -> clap::App<'_> { + fn augment_args_for_update(_app: clap::Command<'_>) -> clap::Command<'_> { unimplemented!() } } diff --git a/clap_derive/src/lib.rs b/clap_derive/src/lib.rs index b68f05725fd..973b61e177c 100644 --- a/clap_derive/src/lib.rs +++ b/clap_derive/src/lib.rs @@ -38,7 +38,7 @@ pub fn arg_enum(input: TokenStream) -> TokenStream { /// Generates the `Parser` implementation. /// -/// This is far less verbose than defining the `clap::App` struct manually, +/// This is far less verbose than defining the `clap::Command` struct manually, /// receiving an instance of `clap::ArgMatches` from conducting parsing, and then /// implementing a conversion code to instantiate an instance of the user /// context struct. diff --git a/clap_derive/src/parse.rs b/clap_derive/src/parse.rs index e20b9e88af8..2973cf670f4 100644 --- a/clap_derive/src/parse.rs +++ b/clap_derive/src/parse.rs @@ -266,12 +266,12 @@ fn raw_method_suggestion(ts: ParseBuffer) -> String { }; format!( - "if you need to call `clap::Arg/App::{}` method you \ + "if you need to call `clap::Arg/Command::{}` method you \ can do it like this: #[clap({}{})]", name, name, suggestion ) } else { - "if you need to call some method from `clap::Arg/App` \ + "if you need to call some method from `clap::Arg/Command` \ you should use raw method, see \ https://github.com/clap-rs/clap/blob/master/examples/derive_ref/README.md#raw-attributes" .into() diff --git a/clap_generate/src/lib.rs b/clap_generate/src/lib.rs index 841865891f3..d13d6a25d16 100644 --- a/clap_generate/src/lib.rs +++ b/clap_generate/src/lib.rs @@ -22,7 +22,7 @@ pub mod utils { #[deprecated(since = "3.0.0", note = "Renamed to `clap_complete::generate_to`")] pub fn generate_to( gen: G, - app: &mut clap::App, + app: &mut clap::Command, bin_name: S, out_dir: T, ) -> Result @@ -35,7 +35,7 @@ where } #[deprecated(since = "3.0.0", note = "Renamed to `clap_complete`")] -pub fn generate(gen: G, app: &mut clap::App, bin_name: S, buf: &mut dyn Write) +pub fn generate(gen: G, app: &mut clap::Command, bin_name: S, buf: &mut dyn Write) where G: Generator, S: Into, diff --git a/clap_generate/tests/warning.rs b/clap_generate/tests/warning.rs index 293b2a34618..3d25fa14992 100644 --- a/clap_generate/tests/warning.rs +++ b/clap_generate/tests/warning.rs @@ -1,16 +1,16 @@ #![allow(deprecated)] -use clap::{App, Arg}; +use clap::{Arg, Command}; use clap_generate::{generate, generators::*}; use std::io; #[test] fn generate_completions() { - let mut app = App::new("test_app") + let mut app = Command::new("test_app") .arg(Arg::new("config").short('c').global(true)) .arg(Arg::new("v").short('v').conflicts_with("config")) .subcommand( - App::new("test") + Command::new("test") .about("Subcommand") .arg(Arg::new("debug").short('d')), ); diff --git a/clap_mangen/README.md b/clap_mangen/README.md index 0b5a0eebd4f..21ee2755bf5 100644 --- a/clap_mangen/README.md +++ b/clap_mangen/README.md @@ -18,7 +18,7 @@ Dual-licensed under [Apache 2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT). ## About -Generate [ROFF](https://en.wikipedia.org/wiki/Roff_(software)) from a `clap::App`. +Generate [ROFF](https://en.wikipedia.org/wiki/Roff_(software)) from a `clap::Command`. ### Example @@ -36,7 +36,7 @@ In your `build.rs`: fn main() -> std::io::Result<()> { let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); - let app = clap::App::new("mybin") + let app = clap::Command::new("mybin") .arg(clap::arg!(-n --name )) .arg(clap::arg!(-c --count )); diff --git a/clap_mangen/examples/man.rs b/clap_mangen/examples/man.rs index 96d267f8f53..2345e1a1c73 100644 --- a/clap_mangen/examples/man.rs +++ b/clap_mangen/examples/man.rs @@ -1,11 +1,11 @@ -use clap::{arg, App}; +use clap::{arg, Command}; use clap_mangen::Man; use std::io; // Run this example as `cargo run --example man | man -l -`. fn main() -> Result<(), std::io::Error> { - let app = App::new("myapp") + let app = Command::new("myapp") .version("1.0") .author("Kevin K. :Ola Nordmann ") .about("Does awesome things") @@ -31,7 +31,7 @@ And a few newlines.", .hide_env(true), ) .subcommand( - App::new("test") + Command::new("test") .about("does testing things") .arg(arg!(-l --list "Lists test values")), ); diff --git a/clap_mangen/src/lib.rs b/clap_mangen/src/lib.rs index 60f6cd91976..b542dd6a285 100644 --- a/clap_mangen/src/lib.rs +++ b/clap_mangen/src/lib.rs @@ -14,7 +14,7 @@ use std::io::Write; /// A manpage writer pub struct Man<'a> { - app: clap::App<'a>, + app: clap::Command<'a>, title: String, section: String, date: String, @@ -25,7 +25,7 @@ pub struct Man<'a> { /// Build a [`Man`] impl<'a> Man<'a> { /// Create a new manual page. - pub fn new(mut app: clap::App<'a>) -> Self { + pub fn new(mut app: clap::Command<'a>) -> Self { app._build_all(); let title = app.get_name().to_owned(); let section = "1".to_owned(); @@ -251,18 +251,18 @@ impl<'a> Man<'a> { } // Does the application have a version? -fn app_has_version(app: &clap::App) -> bool { +fn app_has_version(app: &clap::Command) -> bool { app.get_version() .or_else(|| app.get_long_version()) .is_some() } // Does the application have any command line arguments? -fn app_has_arguments(app: &clap::App) -> bool { +fn app_has_arguments(app: &clap::Command) -> bool { app.get_arguments().any(|i| !i.is_hide_set()) } // Does the application have any subcommands? -fn app_has_subcommands(app: &clap::App) -> bool { +fn app_has_subcommands(app: &clap::Command) -> bool { app.get_subcommands().any(|i| !i.is_hide_set()) } diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs index b6f7a70ee7d..04f80a13b03 100644 --- a/clap_mangen/src/render.rs +++ b/clap_mangen/src/render.rs @@ -1,14 +1,14 @@ use clap::AppSettings; use roff::{bold, italic, roman, Inline, Roff}; -pub(crate) fn subcommand_heading(app: &clap::App) -> String { +pub(crate) fn subcommand_heading(app: &clap::Command) -> String { match app.get_subcommand_help_heading() { Some(title) => title.to_string(), None => "SUBCOMMANDS".to_string(), } } -pub(crate) fn about(roff: &mut Roff, app: &clap::App) { +pub(crate) fn about(roff: &mut Roff, app: &clap::Command) { let s = match app.get_about().or_else(|| app.get_long_about()) { Some(about) => format!("{} - {}", app.get_name(), about), None => app.get_name().to_string(), @@ -16,7 +16,7 @@ pub(crate) fn about(roff: &mut Roff, app: &clap::App) { roff.text([roman(&s)]); } -pub(crate) fn description(roff: &mut Roff, app: &clap::App) { +pub(crate) fn description(roff: &mut Roff, app: &clap::Command) { if let Some(about) = app.get_long_about().or_else(|| app.get_about()) { for line in about.lines() { if line.trim().is_empty() { @@ -28,7 +28,7 @@ pub(crate) fn description(roff: &mut Roff, app: &clap::App) { } } -pub(crate) fn synopsis(roff: &mut Roff, app: &clap::App) { +pub(crate) fn synopsis(roff: &mut Roff, app: &clap::Command) { let mut line = vec![bold(app.get_name()), roman(" ")]; for opt in app.get_arguments() { @@ -80,7 +80,7 @@ pub(crate) fn synopsis(roff: &mut Roff, app: &clap::App) { roff.text(line); } -pub(crate) fn options(roff: &mut Roff, app: &clap::App) { +pub(crate) fn options(roff: &mut Roff, app: &clap::Command) { let items: Vec<_> = app.get_arguments().filter(|i| !i.is_hide_set()).collect(); for opt in items.iter().filter(|a| !a.is_positional()) { @@ -143,7 +143,7 @@ pub(crate) fn options(roff: &mut Roff, app: &clap::App) { } } -pub(crate) fn subcommands(roff: &mut Roff, app: &clap::App, section: &str) { +pub(crate) fn subcommands(roff: &mut Roff, app: &clap::Command, section: &str) { for sub in app.get_subcommands().filter(|s| !s.is_hide_set()) { roff.control("TP", []); @@ -158,7 +158,7 @@ pub(crate) fn subcommands(roff: &mut Roff, app: &clap::App, section: &str) { } } -pub(crate) fn version(app: &clap::App) -> String { +pub(crate) fn version(app: &clap::Command) -> String { format!( "v{}", app.get_long_version() @@ -167,7 +167,7 @@ pub(crate) fn version(app: &clap::App) -> String { ) } -pub(crate) fn after_help(roff: &mut Roff, app: &clap::App) { +pub(crate) fn after_help(roff: &mut Roff, app: &clap::Command) { if let Some(about) = app.get_after_long_help().or_else(|| app.get_after_help()) { for line in about.lines() { roff.text([roman(line)]); @@ -175,7 +175,7 @@ pub(crate) fn after_help(roff: &mut Roff, app: &clap::App) { } } -fn subcommand_markers(cmd: &clap::App) -> (&'static str, &'static str) { +fn subcommand_markers(cmd: &clap::Command) -> (&'static str, &'static str) { #[allow(deprecated)] markers(cmd.is_subcommand_required_set() || cmd.is_set(AppSettings::SubcommandRequiredElseHelp)) } diff --git a/clap_mangen/tests/generate.rs b/clap_mangen/tests/generate.rs index 65b690c0831..3aebb8f64ec 100644 --- a/clap_mangen/tests/generate.rs +++ b/clap_mangen/tests/generate.rs @@ -1,10 +1,10 @@ -use clap::{arg, App}; +use clap::{arg, Command}; use clap_mangen::Man; use std::io; #[test] fn render_manpage() { - let app = App::new("myapp") + let app = Command::new("myapp") .version("1.0") .author("Kevin K. ") .about("Does awesome things") @@ -20,7 +20,7 @@ fn render_manpage() { .arg(arg!([output] "Sets an optional output file").index(1)) .arg(arg!(-d --debug ... "Turn debugging information on")) .subcommand( - App::new("test") + Command::new("test") .about("does testing things") .arg(arg!(-l --list "Lists test values")), ); diff --git a/docs/FAQ.md b/docs/FAQ.md index eef426de3b7..fe212eae49d 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -66,7 +66,7 @@ Previously, we supported: There are also experiments with other APIs: - [fncmd](https://github.com/yuhr/fncmd): function attribute -- [clap-serde](https://github.com/aobatact/clap-serde): create an `App` from a deserializer +- [clap-serde](https://github.com/aobatact/clap-serde): create an `Command` from a deserializer ### Why is there a default subcommand of help? diff --git a/examples/cargo-example.rs b/examples/cargo-example.rs index 51356dc40a5..89e3eb14412 100644 --- a/examples/cargo-example.rs +++ b/examples/cargo-example.rs @@ -1,7 +1,7 @@ // Note: this requires the `cargo` feature fn main() { - let app = clap::App::new("cargo") + let app = clap::Command::new("cargo") .bin_name("cargo") .subcommand_required(true) .subcommand( diff --git a/examples/derive_ref/README.md b/examples/derive_ref/README.md index 917a85bd5d1..03322ba1185 100644 --- a/examples/derive_ref/README.md +++ b/examples/derive_ref/README.md @@ -3,7 +3,7 @@ 1. [Overview](#overview) 2. [Raw Attributes](#raw-attributes) 3. [Magic Attributes](#magic-attributes) - 1. [App Attributes](#app-attributes) + 1. [Command Attributes](#app-attributes) 2. [Arg Attributes](#arg-attributes) 3. [Arg Types](#arg-types) 4. [Arg Enum Attributes](#arg-enum-attributes) @@ -85,7 +85,7 @@ See also the [tutorial](../tutorial_derive/README.md) and [examples](../README.m ## Raw Attributes **Raw attributes** are forwarded directly to the underlying `clap` builder. Any -`App`, `Arg`, or `PossibleValue` method can be used as an attribute. +`Command`, `Arg`, or `PossibleValue` method can be used as an attribute. Raw attributes come in two different syntaxes: ```rust @@ -107,33 +107,33 @@ translated into a mere method call. - Providing of defaults - Special behavior is triggered off of it -### App Attributes +### Command Attributes -These correspond to a `clap::App` which is used for both top-level parsers and +These correspond to a `clap::Command` which is used for both top-level parsers and when defining subcommands. In addition to the raw attributes, the following magic attributes are supported: -- `name = `: `clap::App::name` +- `name = `: `clap::Command::name` - When not present: [crate `name`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-name-field) (`Parser` container), variant name (`Subcommand` variant) -- `version [= ]`: `clap::App::version` +- `version [= ]`: `clap::Command::version` - When not present: no version set - Without ``: defaults to [crate `version`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-version-field) -- `author [= ]`: `clap::App::author` +- `author [= ]`: `clap::Command::author` - When not present: no author set - Without ``: defaults to [crate `authors`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field) -- `about [= ]`: `clap::App::about` +- `about [= ]`: `clap::Command::about` - When not present: [Doc comment summary](#doc-comments) - Without ``: [crate `description`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-description-field) (`Parser` container) - **TIP:** When a doc comment is also present, you most likely want to add `#[clap(long_about = None)]` to clear the doc comment so only `about` gets shown with both `-h` and `--help`. -- `long_about = `: `clap::App::long_about` +- `long_about = `: `clap::Command::long_about` - When not present: [Doc comment](#doc-comments) if there is a blank line, else nothing - `verbatim_doc_comment`: Minimizes pre-processing when converting doc comments to `about` / `long_about` -- `next_display_order`: `clap::App::next_display_order` -- `next_help_heading`: `clap::App::next_help_heading` +- `next_display_order`: `clap::Command::next_display_order` +- `next_help_heading`: `clap::Command::next_help_heading` - When `flatten`ing `Args`, this is scoped to just the args in this struct and any struct `flatten`ed into it -- `rename_all = `: Override default field / variant name case conversion for `App::name` / `Arg::name` +- `rename_all = `: Override default field / variant name case conversion for `Command::name` / `Arg::name` - When not present: `kebab-case` - Available values: `camelCase`, `kebab-case`, `PascalCase`, `SCREAMING_SNAKE_CASE`, `snake_case`, `lower`, `UPPER`, `verbatim` - `rename_all_env = `: Override default field name case conversion for env variables for `clap::Arg::env` @@ -144,7 +144,7 @@ And for `Subcommand` variants: - `skip`: Ignore this variant - `flatten`: Delegates to the variant for more subcommands (must implement `Subcommand`) - `subcommand`: Nest subcommands under the current set of subcommands (must implement `Subcommand`) -- `external_subcommand`: `clap::App::allow_external_subcommand(true)` +- `external_subcommand`: `clap::Command::allow_external_subcommand(true)` - Variant must be either `Variant(Vec)` or `Variant(Vec)` ### Arg Attributes @@ -172,7 +172,7 @@ In addition to the raw attributes, the following magic attributes are supported: - Only `help_heading` can be used with `flatten`. See [clap-rs/clap#3269](https://github.com/clap-rs/clap/issues/3269) for why arg attributes are not generally supported. - - **Tip:** Though we do apply a flattened `Args`'s Parent App Attributes, this + - **Tip:** Though we do apply a flattened `Args`'s Parent Command Attributes, this makes reuse harder. Generally prefer putting the app attributes on the `Parser` or on the flattened field. - `subcommand`: Delegates definition of subcommands to the field (must implement `Subcommand`) @@ -259,7 +259,7 @@ These correspond to a `clap::PossibleValue`. ### Doc Comments In clap, help messages for the whole binary can be specified -via [`App::about`] and [`App::long_about`] while help messages +via [`Command::about`] and [`Command::long_about`] while help messages for individual arguments can be specified via [`Arg::help`] and [`Arg::long_help`]". `long_*` variants are used when user calls the program with @@ -292,8 +292,8 @@ struct Foo { **NOTE:** Attributes have priority over doc comments! -**Top level doc comments always generate `App::about/long_about` calls!** -If you really want to use the `App::about/long_about` methods (you likely don't), +**Top level doc comments always generate `Command::about/long_about` calls!** +If you really want to use the `Command::about/long_about` methods (you likely don't), use the `about` / `long_about` attributes to override the calls generated from the doc comment. To clear `long_about`, you can use `#[clap(long_about = None)]`. @@ -326,10 +326,10 @@ A doc comment consists of three parts: - A blank line (whitespace only) - Detailed description, all the rest -The summary corresponds with `App::about` / `Arg::help`. When a blank line is -present, the whole doc comment will be passed to `App::long_about` / -`Arg::long_help`. Or in other words, a doc may result in just a `App::about` / -`Arg::help` or `App::about` / `Arg::help` and `App::long_about` / +The summary corresponds with `Command::about` / `Arg::help`. When a blank line is +present, the whole doc comment will be passed to `Command::long_about` / +`Arg::long_help`. Or in other words, a doc may result in just a `Command::about` / +`Arg::help` or `Command::about` / `Arg::help` and `Command::long_about` / `Arg::long_help` In addition, when `verbatim_doc_comment` is not present, `clap` applies some preprocessing, including: diff --git a/examples/git.rs b/examples/git.rs index cfb6848f4ab..4bcd1954c7c 100644 --- a/examples/git.rs +++ b/examples/git.rs @@ -2,29 +2,29 @@ use std::path::PathBuf; -use clap::{arg, App}; +use clap::{arg, Command}; fn main() { - let matches = App::new("git") + let matches = Command::new("git") .about("A fictional versioning CLI") .subcommand_required(true) .arg_required_else_help(true) .allow_external_subcommands(true) .allow_invalid_utf8_for_external_subcommands(true) .subcommand( - App::new("clone") + Command::new("clone") .about("Clones repos") .arg(arg!( "The remote to clone")) .arg_required_else_help(true), ) .subcommand( - App::new("push") + Command::new("push") .about("pushes things") .arg(arg!( "The remote to target")) .arg_required_else_help(true), ) .subcommand( - App::new("add") + Command::new("add") .about("adds things") .arg_required_else_help(true) .arg(arg!( ... "Stuff to add").allow_invalid_utf8(true)), diff --git a/examples/multicall-busybox.md b/examples/multicall-busybox.md index 723d03319c0..a09418403f7 100644 --- a/examples/multicall-busybox.md +++ b/examples/multicall-busybox.md @@ -2,7 +2,7 @@ Example of a busybox-style multicall program -See the documentation for `clap::App::multicall` for rationale. +See the documentation for `clap::Command::multicall` for rationale. This example omits every command except true and false, which are the most trivial to implement, diff --git a/examples/multicall-busybox.rs b/examples/multicall-busybox.rs index 8d49fe7269c..83dd018a873 100644 --- a/examples/multicall-busybox.rs +++ b/examples/multicall-busybox.rs @@ -2,20 +2,20 @@ use std::process::exit; -use clap::{App, Arg}; +use clap::{Arg, Command}; -fn applet_commands() -> [App<'static>; 2] { +fn applet_commands() -> [Command<'static>; 2] { [ - App::new("true").about("does nothing successfully"), - App::new("false").about("does nothing unsuccessfully"), + Command::new("true").about("does nothing successfully"), + Command::new("false").about("does nothing unsuccessfully"), ] } fn main() { - let app = App::new(env!("CARGO_CRATE_NAME")) + let app = Command::new(env!("CARGO_CRATE_NAME")) .multicall(true) .subcommand( - App::new("busybox") + Command::new("busybox") .arg_required_else_help(true) .subcommand_value_name("APPLET") .subcommand_help_heading("APPLETS") diff --git a/examples/multicall-hostname.md b/examples/multicall-hostname.md index 1bbb521fc1f..9e17ca16cbc 100644 --- a/examples/multicall-hostname.md +++ b/examples/multicall-hostname.md @@ -2,7 +2,7 @@ Example of a `hostname-style` multicall program -See the documentation for `clap::App::multicall` for rationale. +See the documentation for `clap::Command::multicall` for rationale. This example omits the implementation of displaying address config diff --git a/examples/multicall-hostname.rs b/examples/multicall-hostname.rs index eb19cd47136..ad154796db7 100644 --- a/examples/multicall-hostname.rs +++ b/examples/multicall-hostname.rs @@ -1,14 +1,14 @@ // Note: this requires the `unstable-multicall` feature -use clap::App; +use clap::Command; fn main() { - let app = App::new(env!("CARGO_CRATE_NAME")) + let app = Command::new(env!("CARGO_CRATE_NAME")) .arg_required_else_help(true) .subcommand_value_name("APPLET") .subcommand_help_heading("APPLETS") - .subcommand(App::new("hostname").about("show hostname part of FQDN")) - .subcommand(App::new("dnsdomainname").about("show domain name part of FQDN")); + .subcommand(Command::new("hostname").about("show hostname part of FQDN")) + .subcommand(Command::new("dnsdomainname").about("show domain name part of FQDN")); let app = app.multicall(true); diff --git a/examples/pacman.rs b/examples/pacman.rs index 155e31d6cb2..c088a8fe916 100644 --- a/examples/pacman.rs +++ b/examples/pacman.rs @@ -1,7 +1,7 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; fn main() { - let matches = App::new("pacman") + let matches = Command::new("pacman") .about("package manager utility") .version("5.2.1") .subcommand_required(true) @@ -11,7 +11,7 @@ fn main() { // // Only a few of its arguments are implemented below. .subcommand( - App::new("query") + Command::new("query") .short_flag('Q') .long_flag("query") .about("Query the package database.") @@ -38,7 +38,7 @@ fn main() { // // Only a few of its arguments are implemented below. .subcommand( - App::new("sync") + Command::new("sync") .short_flag('S') .long_flag("sync") .about("Synchronize packages.") diff --git a/examples/tutorial_builder/01_quick.rs b/examples/tutorial_builder/01_quick.rs index f14a9181435..63b58b3725e 100644 --- a/examples/tutorial_builder/01_quick.rs +++ b/examples/tutorial_builder/01_quick.rs @@ -1,4 +1,4 @@ -use clap::{app_from_crate, arg, App}; +use clap::{app_from_crate, arg, Command}; use std::path::Path; fn main() { @@ -17,7 +17,7 @@ fn main() { -d --debug ... "Turn debugging information on" )) .subcommand( - App::new("test") + Command::new("test") .about("does testing things") .arg(arg!(-l --list "lists test values")), ) diff --git a/examples/tutorial_builder/02_apps.rs b/examples/tutorial_builder/02_apps.rs index b607b7f19a7..c9422d64a3a 100644 --- a/examples/tutorial_builder/02_apps.rs +++ b/examples/tutorial_builder/02_apps.rs @@ -1,7 +1,7 @@ -use clap::{arg, App}; +use clap::{arg, Command}; fn main() { - let matches = App::new("MyApp") + let matches = Command::new("MyApp") .version("1.0") .author("Kevin K. ") .about("Does awesome things") diff --git a/examples/tutorial_builder/03_04_subcommands.rs b/examples/tutorial_builder/03_04_subcommands.rs index d5900824ae6..dbf27081381 100644 --- a/examples/tutorial_builder/03_04_subcommands.rs +++ b/examples/tutorial_builder/03_04_subcommands.rs @@ -1,4 +1,4 @@ -use clap::{app_from_crate, arg, App}; +use clap::{app_from_crate, arg, Command}; fn main() { let matches = app_from_crate!() @@ -6,7 +6,7 @@ fn main() { .subcommand_required(true) .arg_required_else_help(true) .subcommand( - App::new("add") + Command::new("add") .about("Adds files to myapp") .arg(arg!([NAME])), ) diff --git a/examples/tutorial_builder/05_01_assert.rs b/examples/tutorial_builder/05_01_assert.rs index 034367e7964..8ba3344b7c4 100644 --- a/examples/tutorial_builder/05_01_assert.rs +++ b/examples/tutorial_builder/05_01_assert.rs @@ -10,7 +10,7 @@ fn main() { println!("PORT = {}", port); } -fn app() -> clap::App<'static> { +fn app() -> clap::Command<'static> { app_from_crate!().arg( arg!() .help("Network port to use") diff --git a/examples/tutorial_builder/README.md b/examples/tutorial_builder/README.md index 59ac563f9bc..9906b386a65 100644 --- a/examples/tutorial_builder/README.md +++ b/examples/tutorial_builder/README.md @@ -63,7 +63,7 @@ Not printing testing lists... ## Configuring the Parser -You use the `App` the start building a parser. +You use the `Command` the start building a parser. [Example:](02_apps.rs) ```console @@ -109,7 +109,7 @@ clap [..] ``` -You can use `App` methods to change the application level behavior of clap. +You can use `Command` methods to change the application level behavior of clap. [Example:](02_app_settings.rs) ```console @@ -264,7 +264,7 @@ NAME: Some("bob") ### Subcommands -Subcommands are defined as `App`s that get added via `App::subcommand`. Each +Subcommands are defined as `Command`s that get added via `Command::subcommand`. Each instance of a Subcommand can have its own version, author(s), Args, and even its own subcommands. @@ -304,7 +304,7 @@ $ 03_04_subcommands add bob ``` -Because we set `App::arg_required_else_help`: +Because we set `Command::arg_required_else_help`: ```console $ 03_04_subcommands ? failed @@ -324,7 +324,7 @@ SUBCOMMANDS: ``` -Because we set `App::propagate_version`: +Because we set `Command::propagate_version`: ```console $ 03_04_subcommands --version clap [..] @@ -642,7 +642,7 @@ Doing work using input input.txt and config config.toml ## Tips -- Proactively check for bad `App` configurations by calling `App::debug_assert` ([example](05_01_assert.rs)) +- Proactively check for bad `Command` configurations by calling `Command::debug_assert` ([example](05_01_assert.rs)) ## Contributing diff --git a/examples/tutorial_derive/README.md b/examples/tutorial_derive/README.md index c8ab0ea5fef..71cde2a990c 100644 --- a/examples/tutorial_derive/README.md +++ b/examples/tutorial_derive/README.md @@ -66,7 +66,7 @@ In addition to this tutorial, see the [derive reference](../derive_ref/README.md ## Configuring the Parser -You use the `App` the start building a parser. +You use the `Command` the start building a parser. [Example:](02_apps.rs) ```console @@ -111,7 +111,7 @@ clap [..] ``` -You can use `App` methods to change the application level behavior of clap. +You can use `Command` methods to change the application level behavior of clap. [Example:](02_app_settings.rs) ```console @@ -266,7 +266,7 @@ name: Some("bob") ### Subcommands -Subcommands are defined as `App`s that get added via `App::subcommand`. Each +Subcommands are defined as `Command`s that get added via `Command::subcommand`. Each instance of a Subcommand can have its own version, author(s), Args, and even its own subcommands. @@ -326,7 +326,7 @@ SUBCOMMANDS: ``` -Because we set `App::propagate_version`: +Because we set `Command::propagate_version`: ```console $ 03_04_subcommands_derive --version clap [..] @@ -610,7 +610,7 @@ Doing work using input input.txt and config config.toml ## Tips -- Proactively check for bad `App` configurations by calling `App::debug_assert` ([example](05_01_assert.rs)) +- Proactively check for bad `Command` configurations by calling `Command::debug_assert` ([example](05_01_assert.rs)) ## Contributing diff --git a/src/build/app_settings.rs b/src/build/app_settings.rs index 7998bc93ac6..7e43cfc7382 100644 --- a/src/build/app_settings.rs +++ b/src/build/app_settings.rs @@ -5,10 +5,10 @@ use std::ops::BitOr; #[cfg(feature = "yaml")] use std::str::FromStr; -#[allow(unused)] -use crate::App; #[allow(unused)] use crate::Arg; +#[allow(unused)] +use crate::Command; // Third party use bitflags::bitflags; @@ -23,29 +23,29 @@ impl Default for AppFlags { } } -/// Application level settings, which affect how [`App`] operates +/// Application level settings, which affect how [`Command`] operates /// /// **NOTE:** When these settings are used, they apply only to current command, and are *not* /// propagated down or up through child or parent subcommands /// -/// [`App`]: crate::App +/// [`Command`]: crate::Command #[derive(Debug, PartialEq, Copy, Clone)] #[non_exhaustive] pub enum AppSettings { - /// Deprecated, replaced with [`App::ignore_errors`] - #[deprecated(since = "3.1.0", note = "Replaced with `App::ignore_errors`")] + /// Deprecated, replaced with [`Command::ignore_errors`] + #[deprecated(since = "3.1.0", note = "Replaced with `Command::ignore_errors`")] IgnoreErrors, /// Deprecated, replace /// ```rust,no_run - /// let app = clap::App::new("app") + /// let app = clap::Command::new("app") /// .global_setting(clap::AppSettings::WaitOnError) /// .arg(clap::arg!(--flag)); /// let m = app.get_matches(); /// ``` /// with /// ```rust - /// let app = clap::App::new("app") + /// let app = clap::Command::new("app") /// .arg(clap::arg!(--flag)); /// let m = match app.try_get_matches() { /// Ok(m) => m, @@ -73,93 +73,93 @@ pub enum AppSettings { )] WaitOnError, - /// Deprecated, replaced with [`App::allow_hyphen_values`] and + /// Deprecated, replaced with [`Command::allow_hyphen_values`] and /// [`Arg::is_allow_hyphen_values_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`" + note = "Replaced with `Command::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`" )] AllowHyphenValues, - /// Deprecated, replaced with [`App::allow_negative_numbers`] and - /// [`App::is_allow_negative_numbers_set`] + /// Deprecated, replaced with [`Command::allow_negative_numbers`] and + /// [`Command::is_allow_negative_numbers_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::allow_negative_numbers` and `App::is_allow_negative_numbers_set`" + note = "Replaced with `Command::allow_negative_numbers` and `Command::is_allow_negative_numbers_set`" )] AllowNegativeNumbers, - /// Deprecated, replaced with [`App::args_override_self`] - #[deprecated(since = "3.1.0", note = "Replaced with `App::args_override_self`")] + /// Deprecated, replaced with [`Command::args_override_self`] + #[deprecated(since = "3.1.0", note = "Replaced with `Command::args_override_self`")] AllArgsOverrideSelf, - /// Deprecated, replaced with [`App::allow_missing_positional`] and - /// [`App::is_allow_missing_positional_set`] + /// Deprecated, replaced with [`Command::allow_missing_positional`] and + /// [`Command::is_allow_missing_positional_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::allow_missing_positional` and `App::is_allow_missing_positional_set`" + note = "Replaced with `Command::allow_missing_positional` and `Command::is_allow_missing_positional_set`" )] AllowMissingPositional, - /// Deprecated, replaced with [`App::trailing_var_arg`] and [`App::is_trailing_var_arg_set`] + /// Deprecated, replaced with [`Command::trailing_var_arg`] and [`Command::is_trailing_var_arg_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::trailing_var_arg` and `App::is_trailing_var_arg_set`" + note = "Replaced with `Command::trailing_var_arg` and `Command::is_trailing_var_arg_set`" )] TrailingVarArg, - /// Deprecated, replaced with [`App::dont_delimit_trailing_values`] and - /// [`App::is_dont_delimit_trailing_values_set`] + /// Deprecated, replaced with [`Command::dont_delimit_trailing_values`] and + /// [`Command::is_dont_delimit_trailing_values_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::dont_delimit_trailing_values` and `App::is_dont_delimit_trailing_values_set`" + note = "Replaced with `Command::dont_delimit_trailing_values` and `Command::is_dont_delimit_trailing_values_set`" )] DontDelimitTrailingValues, - /// Deprecated, replaced with [`App::infer_long_args`] - #[deprecated(since = "3.1.0", note = "Replaced with `App::infer_long_args`")] + /// Deprecated, replaced with [`Command::infer_long_args`] + #[deprecated(since = "3.1.0", note = "Replaced with `Command::infer_long_args`")] InferLongArgs, - /// Deprecated, replaced with [`App::infer_subcommands`] - #[deprecated(since = "3.1.0", note = "Replaced with `App::infer_subcommands`")] + /// Deprecated, replaced with [`Command::infer_subcommands`] + #[deprecated(since = "3.1.0", note = "Replaced with `Command::infer_subcommands`")] InferSubcommands, - /// Deprecated, replaced with [`App::subcommand_required`] and - /// [`App::is_subcommand_required_set`] + /// Deprecated, replaced with [`Command::subcommand_required`] and + /// [`Command::is_subcommand_required_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::subcommand_required` and `App::is_subcommand_required_set`" + note = "Replaced with `Command::subcommand_required` and `Command::is_subcommand_required_set`" )] SubcommandRequired, - /// Deprecated, replaced with [`App::subcommand_required`] combined with - /// [`App::arg_required_else_help`]. + /// Deprecated, replaced with [`Command::subcommand_required`] combined with + /// [`Command::arg_required_else_help`]. #[deprecated( since = "3.1.0", - note = "Replaced with `App::subcommand_required` combined with `App::arg_required_else_help`" + note = "Replaced with `Command::subcommand_required` combined with `Command::arg_required_else_help`" )] SubcommandRequiredElseHelp, - /// Deprecated, replaced with [`App::allow_external_subcommands`] and - /// [`App::is_allow_external_subcommands_set`] + /// Deprecated, replaced with [`Command::allow_external_subcommands`] and + /// [`Command::is_allow_external_subcommands_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::allow_external_subcommands` and `App::is_allow_external_subcommands_set`" + note = "Replaced with `Command::allow_external_subcommands` and `Command::is_allow_external_subcommands_set`" )] AllowExternalSubcommands, - /// Deprecated, replaced with [`App::multicall`] and [`App::is_multicall_set`] + /// Deprecated, replaced with [`Command::multicall`] and [`Command::is_multicall_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::multicall` and `App::is_multicall_set`" + note = "Replaced with `Command::multicall` and `Command::is_multicall_set`" )] #[cfg(feature = "unstable-multicall")] Multicall, - /// Deprecated, replaced with [`App::allow_invalid_utf8_for_external_subcommands`] and [`App::is_allow_invalid_utf8_for_external_subcommands_set`] + /// Deprecated, replaced with [`Command::allow_invalid_utf8_for_external_subcommands`] and [`Command::is_allow_invalid_utf8_for_external_subcommands_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::allow_invalid_utf8_for_external_subcommands` and `App::is_allow_invalid_utf8_for_external_subcommands_set`" + note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set`" )] AllowInvalidUtf8ForExternalSubcommands, @@ -167,131 +167,131 @@ pub enum AppSettings { #[deprecated(since = "3.1.0", note = "This is now the default")] UseLongFormatForHelpSubcommand, - /// Deprecated, replaced with [`App::subcommand_negates_reqs`] and - /// [`App::is_subcommand_negates_reqs_set`] + /// Deprecated, replaced with [`Command::subcommand_negates_reqs`] and + /// [`Command::is_subcommand_negates_reqs_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::subcommand_negates_reqs` and `App::is_subcommand_negates_reqs_set`" + note = "Replaced with `Command::subcommand_negates_reqs` and `Command::is_subcommand_negates_reqs_set`" )] SubcommandsNegateReqs, - /// Deprecated, replaced with [`App::args_conflicts_with_subcommands`] and - /// [`App::is_args_conflicts_with_subcommands_set`] + /// Deprecated, replaced with [`Command::args_conflicts_with_subcommands`] and + /// [`Command::is_args_conflicts_with_subcommands_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::args_conflicts_with_subcommands` and `App::is_args_conflicts_with_subcommands_set`" + note = "Replaced with `Command::args_conflicts_with_subcommands` and `Command::is_args_conflicts_with_subcommands_set`" )] ArgsNegateSubcommands, - /// Deprecated, replaced with [`App::subcommand_precedence_over_arg`] and - /// [`App::is_subcommand_precedence_over_arg_set`] + /// Deprecated, replaced with [`Command::subcommand_precedence_over_arg`] and + /// [`Command::is_subcommand_precedence_over_arg_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::subcommand_precedence_over_arg` and `App::is_subcommand_precedence_over_arg_set`" + note = "Replaced with `Command::subcommand_precedence_over_arg` and `Command::is_subcommand_precedence_over_arg_set`" )] SubcommandPrecedenceOverArg, - /// Deprecated, replaced with [`App::arg_required_else_help`] and - /// [`App::is_arg_required_else_help_set`] + /// Deprecated, replaced with [`Command::arg_required_else_help`] and + /// [`Command::is_arg_required_else_help_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::arg_required_else_help` and `App::is_arg_required_else_help_set`" + note = "Replaced with `Command::arg_required_else_help` and `Command::is_arg_required_else_help_set`" )] ArgRequiredElseHelp, /// Displays the arguments and [`subcommands`] in the help message in the order that they were /// declared in, and not alphabetically which is the default. /// - /// To override the declaration order, see [`Arg::display_order`] and [`App::display_order`]. + /// To override the declaration order, see [`Arg::display_order`] and [`Command::display_order`]. /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, Arg, AppSettings}; + /// Command::new("myprog") /// .global_setting(AppSettings::DeriveDisplayOrder) /// .get_matches(); /// ``` /// - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() /// [`Arg::display_order`]: crate::Arg::display_order - /// [`App::display_order`]: crate::App::display_order + /// [`Command::display_order`]: crate::Command::display_order DeriveDisplayOrder, - /// Deprecated, replaced with [`App::dont_collapse_args_in_usage`] and - /// [`App::is_dont_collapse_args_in_usage_set`] + /// Deprecated, replaced with [`Command::dont_collapse_args_in_usage`] and + /// [`Command::is_dont_collapse_args_in_usage_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::dont_collapse_args_in_usage` and `App::is_dont_collapse_args_in_usage_set`" + note = "Replaced with `Command::dont_collapse_args_in_usage` and `Command::is_dont_collapse_args_in_usage_set`" )] DontCollapseArgsInUsage, - /// Deprecated, replaced with [`App::next_line_help`] and [`App::is_next_line_help_set`] + /// Deprecated, replaced with [`Command::next_line_help`] and [`Command::is_next_line_help_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::next_line_help` and `App::is_next_line_help_set`" + note = "Replaced with `Command::next_line_help` and `Command::is_next_line_help_set`" )] NextLineHelp, - /// Deprecated, replaced with [`App::disable_colored_help`] and - /// [`App::is_disable_colored_help_set`] + /// Deprecated, replaced with [`Command::disable_colored_help`] and + /// [`Command::is_disable_colored_help_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::disable_colored_help` and `App::is_disable_colored_help_set`" + note = "Replaced with `Command::disable_colored_help` and `Command::is_disable_colored_help_set`" )] DisableColoredHelp, - /// Deprecated, replaced with [`App::disable_help_flag`] and [`App::is_disable_help_flag_set`] + /// Deprecated, replaced with [`Command::disable_help_flag`] and [`Command::is_disable_help_flag_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::disable_help_flag` and `App::is_disable_help_flag_set`" + note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set`" )] DisableHelpFlag, - /// Deprecated, replaced with [`App::disable_help_subcommand`] and - /// [`App::is_disable_help_subcommand_set`] + /// Deprecated, replaced with [`Command::disable_help_subcommand`] and + /// [`Command::is_disable_help_subcommand_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::disable_help_subcommand` and `App::is_disable_help_subcommand_set`" + note = "Replaced with `Command::disable_help_subcommand` and `Command::is_disable_help_subcommand_set`" )] DisableHelpSubcommand, - /// Deprecated, replaced with [`App::disable_version_flag`] and - /// [`App::is_disable_version_flag_set`] + /// Deprecated, replaced with [`Command::disable_version_flag`] and + /// [`Command::is_disable_version_flag_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::disable_version_flag` and `App::is_disable_version_flag_set`" + note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set`" )] DisableVersionFlag, - /// Deprecated, replaced with [`App::propagate_version`] and [`App::is_propagate_version_set`] + /// Deprecated, replaced with [`Command::propagate_version`] and [`Command::is_propagate_version_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::propagate_version` and `App::is_propagate_version_set`" + note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set`" )] PropagateVersion, - /// Deprecated, replaced with [`App::hide`] and [`App::is_hide_set`] + /// Deprecated, replaced with [`Command::hide`] and [`Command::is_hide_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::hide` and `App::is_hide_set`" + note = "Replaced with `Command::hide` and `Command::is_hide_set`" )] Hidden, - /// Deprecated, replaced with [`App::hide_possible_values`] and + /// Deprecated, replaced with [`Command::hide_possible_values`] and /// [`Arg::is_hide_possible_values_set`] #[deprecated( since = "3.1.0", - note = "Replaced with `App::hide_possible_values` and `Arg::is_hide_possible_values_set`" + note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set`" )] HidePossibleValues, - /// Deprecated, replaced with [`App::help_expected`] - #[deprecated(since = "3.1.0", note = "Replaced with `App::help_expected`")] + /// Deprecated, replaced with [`Command::help_expected`] + #[deprecated(since = "3.1.0", note = "Replaced with `Command::help_expected`")] HelpExpected, - /// Deprecated, replaced with [`App::no_binary_name`] - #[deprecated(since = "3.1.0", note = "Replaced with `App::no_binary_name`")] + /// Deprecated, replaced with [`Command::no_binary_name`] + #[deprecated(since = "3.1.0", note = "Replaced with `Command::no_binary_name`")] NoBinaryName, /// Treat the auto-generated `-h, --help` flags like any other flag, and *not* print the help @@ -300,8 +300,8 @@ pub enum AppSettings { /// This allows one to handle printing of the help message manually. /// /// ```rust - /// # use clap::{App, AppSettings}; - /// let result = App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// let result = Command::new("myprog") /// .setting(AppSettings::NoAutoHelp) /// .try_get_matches_from("myprog --help".split(" ")); /// @@ -321,8 +321,8 @@ pub enum AppSettings { /// This allows one to handle printing of the version message manually. /// /// ```rust - /// # use clap::{App, AppSettings}; - /// let result = App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// let result = Command::new("myprog") /// .version("3.0") /// .setting(AppSettings::NoAutoVersion) /// .try_get_matches_from("myprog --version".split(" ")); @@ -363,18 +363,18 @@ pub enum AppSettings { #[doc(hidden)] ColoredHelp, - /// Deprecated, see [`App::color`][crate::App::color] - #[deprecated(since = "3.0.0", note = "Replaced with `App::color`")] + /// Deprecated, see [`Command::color`][crate::Command::color] + #[deprecated(since = "3.0.0", note = "Replaced with `Command::color`")] #[doc(hidden)] ColorAuto, - /// Deprecated, replaced with [`App::color`][crate::App::color] - #[deprecated(since = "3.0.0", note = "Replaced with `App::color`")] + /// Deprecated, replaced with [`Command::color`][crate::Command::color] + #[deprecated(since = "3.0.0", note = "Replaced with `Command::color`")] #[doc(hidden)] ColorAlways, - /// Deprecated, replaced with [`App::color`][crate::App::color] - #[deprecated(since = "3.0.0", note = "Replaced with `App::color`")] + /// Deprecated, replaced with [`Command::color`][crate::Command::color] + #[deprecated(since = "3.0.0", note = "Replaced with `Command::color`")] #[doc(hidden)] ColorNever, diff --git a/src/build/arg.rs b/src/build/arg.rs index f923404a38e..a280a3f97d9 100644 --- a/src/build/arg.rs +++ b/src/build/arg.rs @@ -104,7 +104,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("config") /// # ; /// ``` @@ -143,8 +143,8 @@ impl<'help> Arg<'help> { /// argument via a single hyphen (`-`) such as `-c`: /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("config") /// .short('c')) /// .get_matches_from(vec![ @@ -180,8 +180,8 @@ impl<'help> Arg<'help> { /// Setting `long` allows using the argument via a double hyphen (`--`) such as `--config` /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config")) /// .get_matches_from(vec![ @@ -205,8 +205,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .long("test") /// .alias("alias") @@ -231,8 +231,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .short('t') /// .short_alias('e') @@ -259,8 +259,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .long("test") /// .aliases(&["do-stuff", "do-tests", "tests"]) @@ -285,8 +285,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .short('t') /// .short_aliases(&['e', 's']) @@ -313,8 +313,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .visible_alias("something-awesome") /// .long("test") @@ -325,7 +325,7 @@ impl<'help> Arg<'help> { /// assert!(m.is_present("test")); /// assert_eq!(m.value_of("test"), Some("coffee")); /// ``` - /// [`App::alias`]: Arg::alias() + /// [`Command::alias`]: Arg::alias() #[must_use] pub fn visible_alias>(mut self, name: S) -> Self { self.aliases.push((name.into(), true)); @@ -339,8 +339,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .long("test") /// .visible_short_alias('t') @@ -366,8 +366,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .long("test") /// .visible_aliases(&["something", "awesome", "cool"])) @@ -376,7 +376,7 @@ impl<'help> Arg<'help> { /// ]); /// assert!(m.is_present("test")); /// ``` - /// [`App::aliases`]: Arg::aliases() + /// [`Command::aliases`]: Arg::aliases() #[must_use] pub fn visible_aliases(mut self, names: &[&'help str]) -> Self { self.aliases.extend(names.iter().map(|n| (*n, true))); @@ -390,8 +390,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("test") /// .long("test") /// .visible_short_aliases(&['t', 'e'])) @@ -426,22 +426,22 @@ impl<'help> Arg<'help> { /// /// # Panics /// - /// [`App`] will [`panic!`] if indexes are skipped (such as defining `index(1)` and `index(3)` + /// [`Command`] will [`panic!`] if indexes are skipped (such as defining `index(1)` and `index(3)` /// but not `index(2)`, or a positional argument is defined as multiple and is not the highest /// index /// /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("config") /// .index(1) /// # ; /// ``` /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("mode") /// .index(1)) /// .arg(Arg::new("debug") @@ -458,7 +458,7 @@ impl<'help> Arg<'help> { /// [`Arg::long`]: Arg::long() /// [`Arg::multiple_values(true)`]: Arg::multiple_values() /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html - /// [`App`]: crate::App + /// [`Command`]: crate::Command #[inline] #[must_use] pub fn index(mut self, idx: usize) -> Self { @@ -478,7 +478,7 @@ impl<'help> Arg<'help> { /// **NOTE:** This will change the usage string to look like `$ prog [OPTIONS] [-- ]` if /// `ARG` is marked as `.last(true)`. /// - /// **NOTE:** This setting will imply [`crate::App::dont_collapse_args_in_usage`] because failing + /// **NOTE:** This setting will imply [`crate::Command::dont_collapse_args_in_usage`] because failing /// to set this can make the usage string very confusing. /// /// **NOTE**: This setting only applies to positional arguments, and has no effect on OPTIONS @@ -487,8 +487,8 @@ impl<'help> Arg<'help> { /// /// **CAUTION:** Using this setting *and* having child subcommands is not /// recommended with the exception of *also* using - /// [`crate::App::args_conflicts_with_subcommands`] - /// (or [`crate::App::subcommand_negates_reqs`] if the argument marked `Last` is also + /// [`crate::Command::args_conflicts_with_subcommands`] + /// (or [`crate::Command::subcommand_negates_reqs`] if the argument marked `Last` is also /// marked [`Arg::required`]) /// /// # Examples @@ -505,8 +505,8 @@ impl<'help> Arg<'help> { /// and requires that the `--` syntax be used to access it early. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("first")) /// .arg(Arg::new("second")) /// .arg(Arg::new("third") @@ -526,8 +526,8 @@ impl<'help> Arg<'help> { /// failing to use the `--` syntax results in an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("first")) /// .arg(Arg::new("second")) /// .arg(Arg::new("third") @@ -576,8 +576,8 @@ impl<'help> Arg<'help> { /// Setting required requires that the argument be used at runtime. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required(true) /// .takes_value(true) @@ -592,8 +592,8 @@ impl<'help> Arg<'help> { /// Setting required and then *not* supplying that argument at runtime is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required(true) /// .takes_value(true) @@ -635,8 +635,8 @@ impl<'help> Arg<'help> { /// required /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires("input") @@ -653,8 +653,8 @@ impl<'help> Arg<'help> { /// Setting [`Arg::requires(name)`] and *not* supplying that argument is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires("input") @@ -692,8 +692,8 @@ impl<'help> Arg<'help> { /// is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("exclusive") /// .takes_value(true) /// .exclusive(true) @@ -733,14 +733,14 @@ impl<'help> Arg<'help> { /// want to clutter the source with three duplicate [`Arg`] definitions. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("verb") /// .long("verbose") /// .short('v') /// .global(true)) - /// .subcommand(App::new("test")) - /// .subcommand(App::new("do-stuff")) + /// .subcommand(Command::new("test")) + /// .subcommand(Command::new("do-stuff")) /// .get_matches_from(vec![ /// "prog", "do-stuff", "--verbose" /// ]); @@ -776,8 +776,8 @@ impl<'help> Arg<'help> { /// An example with flags /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("verbose") /// .multiple_occurrences(true) /// .short('v')) @@ -792,8 +792,8 @@ impl<'help> Arg<'help> { /// An example with options /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("file") /// .multiple_occurrences(true) /// .takes_value(true) @@ -827,7 +827,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("verbosity") /// .short('v') /// .max_occurrences(3); @@ -836,8 +836,8 @@ impl<'help> Arg<'help> { /// Supplying less than the maximum number of arguments is allowed /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("verbosity") /// .max_occurrences(3) /// .short('v')) @@ -853,8 +853,8 @@ impl<'help> Arg<'help> { /// Supplying more than the maximum number of arguments is an error /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("verbosity") /// .max_occurrences(2) /// .short('v')) @@ -965,8 +965,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .takes_value(true)) @@ -1047,8 +1047,8 @@ impl<'help> Arg<'help> { /// An example with options /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .multiple_values(true) @@ -1066,8 +1066,8 @@ impl<'help> Arg<'help> { /// Although `multiple_values` has been specified, we cannot use the argument more than once. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .multiple_values(true) @@ -1084,8 +1084,8 @@ impl<'help> Arg<'help> { /// argument. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .multiple_values(true) @@ -1110,8 +1110,8 @@ impl<'help> Arg<'help> { /// number, or to say [`Arg::multiple_occurrences`] is ok, but multiple values is not. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .multiple_occurrences(true) @@ -1132,8 +1132,8 @@ impl<'help> Arg<'help> { /// As a final example, let's fix the above error and get a pretty message to the user :) /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .multiple_occurrences(true) @@ -1148,7 +1148,7 @@ impl<'help> Arg<'help> { /// assert_eq!(res.unwrap_err().kind(), ErrorKind::UnknownArgument); /// ``` /// - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() /// [`Arg::number_of_values(1)`]: Arg::number_of_values() /// [maximum number of values]: Arg::max_values() /// [specific number of values]: Arg::number_of_values() @@ -1180,7 +1180,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("file") /// .short('f') /// .number_of_values(3); @@ -1189,8 +1189,8 @@ impl<'help> Arg<'help> { /// Not supplying the correct number of values is an error /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .number_of_values(2) @@ -1225,7 +1225,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("file") /// .short('f') /// .max_values(3); @@ -1234,8 +1234,8 @@ impl<'help> Arg<'help> { /// Supplying less than the maximum number of values is allowed /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .max_values(3) @@ -1253,8 +1253,8 @@ impl<'help> Arg<'help> { /// Supplying more than the maximum number of values is an error /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .max_values(2) @@ -1290,7 +1290,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("file") /// .short('f') /// .min_values(3); @@ -1299,8 +1299,8 @@ impl<'help> Arg<'help> { /// Supplying more than the minimum number of values is allowed /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .min_values(2) @@ -1318,8 +1318,8 @@ impl<'help> Arg<'help> { /// Supplying less than the minimum number of values is an error /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .takes_value(true) /// .min_values(2) @@ -1351,7 +1351,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("cfg") /// .long("config") /// .value_name("FILE") @@ -1359,8 +1359,8 @@ impl<'help> Arg<'help> { /// ``` /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("config") /// .long("config") /// .value_name("FILE") @@ -1410,15 +1410,15 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("speed") /// .short('s') /// .value_names(&["fast", "slow"]); /// ``` /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("io") /// .long("io-files") /// .value_names(&["INFILE", "OUTFILE"])) @@ -1469,8 +1469,8 @@ impl<'help> Arg<'help> { /// To take a full command line and its arguments (for example, when writing a command wrapper): /// /// ``` - /// # use clap::{App, Arg, ValueHint}; - /// App::new("prog") + /// # use clap::{Command, Arg, ValueHint}; + /// Command::new("prog") /// .trailing_var_arg(true) /// .arg( /// Arg::new("command") @@ -1504,12 +1504,12 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// fn has_at(v: &str) -> Result<(), String> { /// if v.contains("@") { return Ok(()); } /// Err(String::from("The value did not contain the required @ sigil")) /// } - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .index(1) /// .validator(has_at)) @@ -1542,14 +1542,14 @@ impl<'help> Arg<'help> { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```rust")] - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// # use std::ffi::{OsStr, OsString}; /// # use std::os::unix::ffi::OsStrExt; /// fn has_ampersand(v: &OsStr) -> Result<(), String> { /// if v.as_bytes().iter().any(|b| *b == b'&') { return Ok(()); } /// Err(String::from("The value did not contain the required & sigil")) /// } - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("file") /// .index(1) /// .validator_os(has_ampersand)) @@ -1596,12 +1596,12 @@ impl<'help> Arg<'help> { /// You can use the classical `"\d+"` regular expression to match digits only: /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// use regex::Regex; /// /// let digits = Regex::new(r"\d+").unwrap(); /// - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("digits") /// .index(1) /// .validator_regex(&digits, "only digits are allowed")) @@ -1615,12 +1615,12 @@ impl<'help> Arg<'help> { /// However, any valid `Regex` can be used: /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; + /// # use clap::{Command, Arg, ErrorKind}; /// use regex::Regex; /// /// let priority = Regex::new(r"[A-C]").unwrap(); /// - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("priority") /// .index(1) /// .validator_regex(priority, "only priorities A, B or C are allowed")) @@ -1660,7 +1660,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("mode") /// .takes_value(true) /// .possible_value("fast") @@ -1671,7 +1671,7 @@ impl<'help> Arg<'help> { /// The same using [`PossibleValue`]: /// /// ```rust - /// # use clap::{App, Arg, PossibleValue}; + /// # use clap::{Command, Arg, PossibleValue}; /// Arg::new("mode").takes_value(true) /// .possible_value(PossibleValue::new("fast")) /// // value with a help text @@ -1682,8 +1682,8 @@ impl<'help> Arg<'help> { /// ``` /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .takes_value(true) @@ -1701,8 +1701,8 @@ impl<'help> Arg<'help> { /// possible values. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .takes_value(true) @@ -1741,7 +1741,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("mode") /// .takes_value(true) /// .possible_values(["fast", "slow", "medium"]) @@ -1750,7 +1750,7 @@ impl<'help> Arg<'help> { /// The same using [`PossibleValue`]: /// /// ```rust - /// # use clap::{App, Arg, PossibleValue}; + /// # use clap::{Command, Arg, PossibleValue}; /// Arg::new("mode").takes_value(true).possible_values([ /// PossibleValue::new("fast"), /// // value with a help text @@ -1762,8 +1762,8 @@ impl<'help> Arg<'help> { /// ``` /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .takes_value(true) @@ -1779,8 +1779,8 @@ impl<'help> Arg<'help> { /// possible values. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .takes_value(true) @@ -1819,8 +1819,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("pv") + /// # use clap::{Command, Arg}; + /// let m = Command::new("pv") /// .arg(Arg::new("option") /// .long("--option") /// .takes_value(true) @@ -1836,8 +1836,8 @@ impl<'help> Arg<'help> { /// This setting also works when multiple values can be defined: /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("pv") + /// # use clap::{Command, Arg}; + /// let m = Command::new("pv") /// .arg(Arg::new("option") /// .short('o') /// .long("--option") @@ -1882,8 +1882,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("pat") /// .takes_value(true) /// .allow_hyphen_values(true) @@ -1899,8 +1899,8 @@ impl<'help> Arg<'help> { /// hyphen is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("pat") /// .takes_value(true) /// .long("pattern")) @@ -1935,10 +1935,10 @@ impl<'help> Arg<'help> { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```rust")] - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// use std::ffi::OsString; /// use std::os::unix::ffi::{OsStrExt,OsStringExt}; - /// let r = App::new("myprog") + /// let r = Command::new("myprog") /// .arg(Arg::new("arg").allow_invalid_utf8(true)) /// .try_get_matches_from(vec![ /// OsString::from("myprog"), @@ -1977,8 +1977,8 @@ impl<'help> Arg<'help> { /// The default is allowing empty values. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .short('v') @@ -1994,8 +1994,8 @@ impl<'help> Arg<'help> { /// By adding this setting, we can forbid empty values. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .short('v') @@ -2030,8 +2030,8 @@ impl<'help> Arg<'help> { /// it and the associated value. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .require_equals(true) @@ -2047,8 +2047,8 @@ impl<'help> Arg<'help> { /// error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .require_equals(true) @@ -2087,8 +2087,8 @@ impl<'help> Arg<'help> { /// The following example shows the default behavior. /// /// ```rust - /// # use clap::{App, Arg}; - /// let delims = App::new("prog") + /// # use clap::{Command, Arg}; + /// let delims = Command::new("prog") /// .arg(Arg::new("option") /// .long("option") /// .use_value_delimiter(true) @@ -2105,8 +2105,8 @@ impl<'help> Arg<'help> { /// behavior /// /// ```rust - /// # use clap::{App, Arg}; - /// let nodelims = App::new("prog") + /// # use clap::{Command, Arg}; + /// let nodelims = Command::new("prog") /// .arg(Arg::new("option") /// .long("option") /// .takes_value(true)) @@ -2151,8 +2151,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("config") /// .short('c') /// .long("config") @@ -2192,8 +2192,8 @@ impl<'help> Arg<'help> { /// everything works in this first example, as we use a delimiter, as expected. /// /// ```rust - /// # use clap::{App, Arg}; - /// let delims = App::new("prog") + /// # use clap::{Command, Arg}; + /// let delims = Command::new("prog") /// .arg(Arg::new("opt") /// .short('o') /// .takes_value(true) @@ -2211,8 +2211,8 @@ impl<'help> Arg<'help> { /// In this next example, we will *not* use a delimiter. Notice it's now an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("opt") /// .short('o') /// .takes_value(true) @@ -2235,8 +2235,8 @@ impl<'help> Arg<'help> { /// is *not* an error. /// /// ```rust - /// # use clap::{App, Arg}; - /// let delims = App::new("prog") + /// # use clap::{Command, Arg}; + /// let delims = Command::new("prog") /// .arg(Arg::new("opt") /// .short('o') /// .takes_value(true) @@ -2282,7 +2282,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("vals") /// .takes_value(true) /// .multiple_values(true) @@ -2294,8 +2294,8 @@ impl<'help> Arg<'help> { /// to perform them /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cmds") /// .takes_value(true) /// .multiple_values(true) @@ -2334,7 +2334,7 @@ impl<'help> Arg<'help> { /// ``` /// /// Will result in everything after `--` to be considered one raw argument. This behavior - /// may not be exactly what you are expecting and using [`crate::App::trailing_var_arg`] + /// may not be exactly what you are expecting and using [`crate::Command::trailing_var_arg`] /// may be more appropriate. /// /// **NOTE:** Implicitly sets [`Arg::takes_value(true)`] [`Arg::multiple_values(true)`], @@ -2378,8 +2378,8 @@ impl<'help> Arg<'help> { /// First we use the default value without providing any value at runtime. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .long("myopt") /// .default_value("myval")) @@ -2395,8 +2395,8 @@ impl<'help> Arg<'help> { /// Next we provide a value at runtime to override the default. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .long("myopt") /// .default_value("myval")) @@ -2472,11 +2472,11 @@ impl<'help> Arg<'help> { /// Here is an implementation of the common POSIX style `--color` argument. /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// /// macro_rules! app { /// () => {{ - /// App::new("prog") + /// Command::new("prog") /// .arg(Arg::new("color").long("color") /// .value_name("WHEN") /// .possible_values(["always", "auto", "never"]) @@ -2591,11 +2591,11 @@ impl<'help> Arg<'help> { /// /// ```rust /// # use std::env; - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// /// env::set_var("MY_FLAG", "env"); /// - /// let m = App::new("prog") + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag") /// .env("MY_FLAG") @@ -2615,12 +2615,12 @@ impl<'help> Arg<'help> { /// /// ```rust /// # use std::env; - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// /// env::set_var("TRUE_FLAG", "true"); /// env::set_var("FALSE_FLAG", "0"); /// - /// let m = App::new("prog") + /// let m = Command::new("prog") /// .arg(Arg::new("true_flag") /// .long("true_flag") /// .env("TRUE_FLAG")) @@ -2644,11 +2644,11 @@ impl<'help> Arg<'help> { /// /// ```rust /// # use std::env; - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// /// env::set_var("MY_FLAG", "env"); /// - /// let m = App::new("prog") + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag") /// .env("MY_FLAG") @@ -2665,11 +2665,11 @@ impl<'help> Arg<'help> { /// /// ```rust /// # use std::env; - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// /// env::set_var("MY_FLAG", "env"); /// - /// let m = App::new("prog") + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag") /// .env("MY_FLAG") @@ -2686,11 +2686,11 @@ impl<'help> Arg<'help> { /// /// ```rust /// # use std::env; - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// /// env::set_var("MY_FLAG_MULTI", "env1,env2"); /// - /// let m = App::new("prog") + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag") /// .env("MY_FLAG_MULTI") @@ -2747,8 +2747,8 @@ impl<'help> Arg<'help> { /// `-h` or `--help` (by default). /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .help("Some help text describing the --config arg")) @@ -2797,8 +2797,8 @@ impl<'help> Arg<'help> { /// `-h` or `--help` (by default). /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .long_help( @@ -2854,8 +2854,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("a") // Typically args are grouped alphabetically by name. /// // Args without a display_order have a value of 999 and are /// // displayed alphabetically with all other 999 valued args. @@ -2902,7 +2902,7 @@ impl<'help> Arg<'help> { /// Override the [current] help section. /// - /// [current]: crate::App::help_heading + /// [current]: crate::Command::help_heading #[inline] #[must_use] pub fn help_heading(mut self, heading: O) -> Self @@ -2919,13 +2919,13 @@ impl<'help> Arg<'help> { /// This can also be helpful for arguments with very long flag names, or many/long value names. /// /// **NOTE:** To apply this setting to all arguments and subcommands, consider using - /// [`crate::App::next_line_help`] + /// [`crate::Command::next_line_help`] /// /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .long("long-option-flag") /// .short('o') @@ -2975,8 +2975,8 @@ impl<'help> Arg<'help> { /// Setting `Hidden` will hide the argument when displaying help text /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .hide(true) @@ -3016,13 +3016,13 @@ impl<'help> Arg<'help> { /// **NOTE:** Setting this requires [`Arg::takes_value`] /// /// To set this for all arguments, see - /// [`App::hide_possible_values`][crate::App::hide_possible_values]. + /// [`Command::hide_possible_values`][crate::Command::hide_possible_values]. /// /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .possible_values(["fast", "slow"]) @@ -3050,8 +3050,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("connect") + /// # use clap::{Command, Arg}; + /// let m = Command::new("connect") /// .arg(Arg::new("host") /// .long("host") /// .default_value("localhost") @@ -3079,8 +3079,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("mode") /// .long("mode") /// .env("MODE") @@ -3108,8 +3108,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("connect") + /// # use clap::{Command, Arg}; + /// let m = Command::new("connect") /// .arg(Arg::new("host") /// .long("host") /// .env("CONNECT") @@ -3141,7 +3141,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("debug") /// .hide_short_help(true); /// ``` @@ -3149,8 +3149,8 @@ impl<'help> Arg<'help> { /// Setting `hide_short_help(true)` will hide the argument when displaying short help text /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .hide_short_help(true) @@ -3176,8 +3176,8 @@ impl<'help> Arg<'help> { /// However, when --help is called /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .hide_short_help(true) @@ -3222,8 +3222,8 @@ impl<'help> Arg<'help> { /// Setting `hide_long_help(true)` will hide the argument when displaying long help text /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .hide_long_help(true) @@ -3249,8 +3249,8 @@ impl<'help> Arg<'help> { /// However, when -h is called /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("cfg") /// .long("config") /// .hide_long_help(true) @@ -3291,7 +3291,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("debug") /// .long("debug") /// .group("mode") @@ -3302,8 +3302,8 @@ impl<'help> Arg<'help> { /// was one of said arguments. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("debug") /// .long("debug") /// .group("mode")) @@ -3328,7 +3328,7 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// Arg::new("debug") /// .long("debug") /// .groups(&["mode", "verbosity"]) @@ -3339,8 +3339,8 @@ impl<'help> Arg<'help> { /// was one of said arguments. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("debug") /// .long("debug") /// .groups(&["mode", "verbosity"])) @@ -3382,8 +3382,8 @@ impl<'help> Arg<'help> { /// First we use the default value only if another arg is present at runtime. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag")) /// .arg(Arg::new("other") @@ -3399,8 +3399,8 @@ impl<'help> Arg<'help> { /// Next we run the same test, but without providing `--flag`. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag")) /// .arg(Arg::new("other") @@ -3416,8 +3416,8 @@ impl<'help> Arg<'help> { /// Now lets only use the default value if `--opt` contains the value `special`. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .takes_value(true) /// .long("opt")) @@ -3435,8 +3435,8 @@ impl<'help> Arg<'help> { /// default value. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("opt") /// .takes_value(true) /// .long("opt")) @@ -3454,8 +3454,8 @@ impl<'help> Arg<'help> { /// value of some other Arg. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag")) /// .arg(Arg::new("other") @@ -3509,8 +3509,8 @@ impl<'help> Arg<'help> { /// First we use the default value only if another arg is present at runtime. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag")) /// .arg(Arg::new("opt") @@ -3532,8 +3532,8 @@ impl<'help> Arg<'help> { /// Next we run the same test, but without providing `--flag`. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag")) /// .arg(Arg::new("other") @@ -3553,8 +3553,8 @@ impl<'help> Arg<'help> { /// true, only the first evaluated "wins" /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .arg(Arg::new("flag") /// .long("flag")) /// .arg(Arg::new("opt") @@ -3619,8 +3619,8 @@ impl<'help> Arg<'help> { /// but it's not an error because the `unless` arg has been supplied. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present("dbg") /// .takes_value(true) @@ -3637,8 +3637,8 @@ impl<'help> Arg<'help> { /// Setting `Arg::required_unless_present(name)` and *not* supplying `name` or this arg is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present("dbg") /// .takes_value(true) @@ -3681,8 +3681,8 @@ impl<'help> Arg<'help> { /// because *all* of the `names` args have been supplied. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present_all(&["dbg", "infile"]) /// .takes_value(true) @@ -3703,8 +3703,8 @@ impl<'help> Arg<'help> { /// either *all* of `unless` args or the `self` arg is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present_all(&["dbg", "infile"]) /// .takes_value(true) @@ -3758,8 +3758,8 @@ impl<'help> Arg<'help> { /// have been supplied. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present_any(&["dbg", "infile"]) /// .takes_value(true) @@ -3780,8 +3780,8 @@ impl<'help> Arg<'help> { /// or this arg is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_unless_present_any(&["dbg", "infile"]) /// .takes_value(true) @@ -3824,8 +3824,8 @@ impl<'help> Arg<'help> { /// ``` /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .required_if_eq("other", "special") @@ -3839,7 +3839,7 @@ impl<'help> Arg<'help> { /// /// assert!(res.is_ok()); // We didn't use --other=special, so "cfg" wasn't required /// - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .required_if_eq("other", "special") @@ -3855,7 +3855,7 @@ impl<'help> Arg<'help> { /// assert!(res.is_err()); /// assert_eq!(res.unwrap_err().kind(), ErrorKind::MissingRequiredArgument); /// - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .required_if_eq("other", "special") @@ -3870,7 +3870,7 @@ impl<'help> Arg<'help> { /// // By default, the comparison is case-sensitive, so "cfg" wasn't required /// assert!(res.is_ok()); /// - /// let res = App::new("prog") + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .required_if_eq("other", "special") @@ -3918,8 +3918,8 @@ impl<'help> Arg<'help> { /// anything other than `val`, this argument isn't required. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_if_eq_any(&[ /// ("extra", "val"), @@ -3944,8 +3944,8 @@ impl<'help> Arg<'help> { /// value of `val` but *not* using this arg is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_if_eq_any(&[ /// ("extra", "val"), @@ -3998,8 +3998,8 @@ impl<'help> Arg<'help> { /// anything other than `val`, this argument isn't required. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_if_eq_all(&[ /// ("extra", "val"), @@ -4024,8 +4024,8 @@ impl<'help> Arg<'help> { /// value of `val` but *not* using this arg is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .required_if_eq_all(&[ /// ("extra", "val"), @@ -4074,8 +4074,8 @@ impl<'help> Arg<'help> { /// `val`, the other argument isn't required. /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires_if("my.cfg", "other") @@ -4092,8 +4092,8 @@ impl<'help> Arg<'help> { /// `arg` is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires_if("my.cfg", "input") @@ -4137,8 +4137,8 @@ impl<'help> Arg<'help> { /// than `val`, `arg` isn't required. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires_ifs(&[ @@ -4190,8 +4190,8 @@ impl<'help> Arg<'help> { /// argument isn't required /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires("input") @@ -4211,8 +4211,8 @@ impl<'help> Arg<'help> { /// error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .requires_all(&["input", "output"]) @@ -4263,8 +4263,8 @@ impl<'help> Arg<'help> { /// Setting conflicting argument, and having both arguments present at runtime is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .conflicts_with("debug") @@ -4313,8 +4313,8 @@ impl<'help> Arg<'help> { /// conflicting argument is an error. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("cfg") /// .takes_value(true) /// .conflicts_with_all(&["debug", "input"]) @@ -4355,9 +4355,9 @@ impl<'help> Arg<'help> { /// /// # Examples /// - /// ```rust # use clap::{App, Arg}; - /// # use clap::{App, arg}; - /// let m = App::new("prog") + /// ```rust # use clap::{Command, Arg}; + /// # use clap::{Command, arg}; + /// let m = Command::new("prog") /// .arg(arg!(-f --flag "some flag") /// .conflicts_with("debug")) /// .arg(arg!(-d --debug "other flag")) @@ -4381,8 +4381,8 @@ impl<'help> Arg<'help> { /// preventing a "Unexpected multiple usage" error): /// /// ```rust - /// # use clap::{App, arg}; - /// let m = App::new("posix") + /// # use clap::{Command, arg}; + /// let m = Command::new("posix") /// .arg(arg!(--flag "some flag").overrides_with("flag")) /// .get_matches_from(vec!["posix", "--flag", "--flag"]); /// assert!(m.is_present("flag")); @@ -4394,8 +4394,8 @@ impl<'help> Arg<'help> { /// if it's a flag and it already accepts multiple occurrences. /// /// ``` - /// # use clap::{App, arg}; - /// let m = App::new("posix") + /// # use clap::{Command, arg}; + /// let m = Command::new("posix") /// .arg(arg!(--flag ... "some flag").overrides_with("flag")) /// .get_matches_from(vec!["", "--flag", "--flag", "--flag", "--flag"]); /// assert!(m.is_present("flag")); @@ -4407,8 +4407,8 @@ impl<'help> Arg<'help> { /// occurrence happened. /// /// ``` - /// # use clap::{App, arg}; - /// let m = App::new("posix") + /// # use clap::{Command, arg}; + /// let m = Command::new("posix") /// .arg(arg!(--opt "some option").overrides_with("opt")) /// .get_matches_from(vec!["", "--opt=some", "--opt=other"]); /// assert!(m.is_present("opt")); @@ -4419,8 +4419,8 @@ impl<'help> Arg<'help> { /// This will also work when [`Arg::multiple_values`] is enabled: /// /// ``` - /// # use clap::{App, Arg}; - /// let m = App::new("posix") + /// # use clap::{Command, Arg}; + /// let m = Command::new("posix") /// .arg( /// Arg::new("opt") /// .long("opt") @@ -4438,8 +4438,8 @@ impl<'help> Arg<'help> { /// will ignore the "override self" setting. /// /// ``` - /// # use clap::{App, arg}; - /// let m = App::new("posix") + /// # use clap::{Command, arg}; + /// let m = Command::new("posix") /// .arg(arg!(--opt ... "some option") /// .multiple_values(true) /// .overrides_with("opt")) @@ -4465,8 +4465,8 @@ impl<'help> Arg<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, arg}; - /// let m = App::new("prog") + /// # use clap::{Command, arg}; + /// let m = Command::new("prog") /// .arg(arg!(-f --flag "some flag") /// .conflicts_with("color")) /// .arg(arg!(-d --debug "other flag")) diff --git a/src/build/arg_group.rs b/src/build/arg_group.rs index b635a23725f..53d2ca07700 100644 --- a/src/build/arg_group.rs +++ b/src/build/arg_group.rs @@ -37,8 +37,8 @@ use yaml_rust::Yaml; /// the arguments from the specified group is present at runtime. /// /// ```rust -/// # use clap::{App, arg, ArgGroup, ErrorKind}; -/// let result = App::new("app") +/// # use clap::{Command, arg, ArgGroup, ErrorKind}; +/// let result = Command::new("app") /// .arg(arg!(--"set-ver" "set the version manually").required(false)) /// .arg(arg!(--major "auto increase major")) /// .arg(arg!(--minor "auto increase minor")) @@ -55,8 +55,8 @@ use yaml_rust::Yaml; /// This next example shows a passing parse of the same scenario /// /// ```rust -/// # use clap::{App, arg, ArgGroup}; -/// let result = App::new("app") +/// # use clap::{Command, arg, ArgGroup}; +/// let result = Command::new("app") /// .arg(arg!(--"set-ver" "set the version manually").required(false)) /// .arg(arg!(--major "auto increase major")) /// .arg(arg!(--minor "auto increase minor")) @@ -104,7 +104,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ArgGroup}; + /// # use clap::{Command, ArgGroup}; /// ArgGroup::new("config") /// # ; /// ``` @@ -117,7 +117,7 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ArgGroup}; + /// # use clap::{Command, ArgGroup}; /// ArgGroup::default().name("config") /// # ; /// ``` @@ -139,8 +139,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup}; + /// let m = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -166,8 +166,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup}; + /// let m = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -197,8 +197,8 @@ impl<'help> ArgGroup<'help> { /// group /// /// ```rust - /// # use clap::{App, Arg, ArgGroup}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup}; + /// let m = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -214,8 +214,8 @@ impl<'help> ArgGroup<'help> { /// an error if more than one of the args in the group was used. /// /// ```rust - /// # use clap::{App, Arg, ArgGroup, ErrorKind}; - /// let result = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup, ErrorKind}; + /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -242,7 +242,7 @@ impl<'help> ArgGroup<'help> { /// This is unless conflicting with another argument. A required group will be displayed in /// the usage string of the application in the format ``. /// - /// **NOTE:** This setting only applies to the current [`App`] / [`Subcommand`]s, and not + /// **NOTE:** This setting only applies to the current [`Command`] / [`Subcommand`]s, and not /// globally. /// /// **NOTE:** By default, [`ArgGroup::multiple`] is set to `false` which when combined with @@ -253,8 +253,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup, ErrorKind}; - /// let result = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup, ErrorKind}; + /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -271,7 +271,7 @@ impl<'help> ArgGroup<'help> { /// /// [`Subcommand`]: crate::Subcommand /// [`ArgGroup::multiple`]: ArgGroup::multiple() - /// [`App`]: crate::App + /// [`Command`]: crate::Command #[inline] #[must_use] pub fn required(mut self, yes: bool) -> Self { @@ -290,8 +290,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup, ErrorKind}; - /// let result = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup, ErrorKind}; + /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -327,8 +327,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup, ErrorKind}; - /// let result = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup, ErrorKind}; + /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -368,8 +368,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup, ErrorKind}; - /// let result = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup, ErrorKind}; + /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") @@ -402,8 +402,8 @@ impl<'help> ArgGroup<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ArgGroup, ErrorKind}; - /// let result = App::new("myprog") + /// # use clap::{Command, Arg, ArgGroup, ErrorKind}; + /// let result = Command::new("myprog") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("color") diff --git a/src/build/command.rs b/src/build/command.rs index dc25447fdca..cf555cd76ed 100644 --- a/src/build/command.rs +++ b/src/build/command.rs @@ -35,19 +35,19 @@ use crate::build::debug_asserts::assert_app; /// /// This includes defining arguments, subcommands, parser behavior, and help output. /// Once all configuration is complete, -/// the [`App::get_matches`] family of methods starts the runtime-parsing +/// the [`Command::get_matches`] family of methods starts the runtime-parsing /// process. These methods then return information about the user supplied /// arguments (or lack thereof). /// /// When deriving a [`Parser`][crate::Parser], you can use /// [`IntoApp::into_app`][crate::IntoApp::into_app] to access the -/// `App`. +/// `Command`. /// /// # Examples /// /// ```no_run -/// # use clap::{App, Arg}; -/// let m = App::new("My Program") +/// # use clap::{Command, Arg}; +/// let m = Command::new("My Program") /// .author("Me, me@mail.com") /// .version("1.0.2") /// .about("Explains in brief what the program does") @@ -60,7 +60,7 @@ use crate::build::debug_asserts::assert_app; /// /// // Your program logic starts here... /// ``` -/// [`App::get_matches`]: App::get_matches() +/// [`App::get_matches`]: Command::get_matches() pub type Command<'help> = App<'help>; /// Deprecated, replaced with [`Command`] @@ -104,7 +104,7 @@ pub struct App<'help> { /// Basic API impl<'help> App<'help> { - /// Creates a new instance of an `App`. + /// Creates a new instance of an `Command`. /// /// It is common, but not required, to use binary name as the `name`. This /// name will only be displayed to the user when they request to print @@ -115,8 +115,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("My Program") + /// # use clap::Command; + /// Command::new("My Program") /// # ; /// ``` pub fn new>(name: S) -> Self { @@ -154,8 +154,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, arg, Arg}; - /// App::new("myprog") + /// # use clap::{Command, arg, Arg}; + /// Command::new("myprog") /// // Adding a single "flag" argument with a short and help text, using Arg::new() /// .arg( /// Arg::new("debug") @@ -191,8 +191,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, arg, Arg}; - /// App::new("myprog") + /// # use clap::{Command, arg, Arg}; + /// Command::new("myprog") /// .args(&[ /// arg!("[debug] -d 'turns on debugging info'"), /// Arg::new("input").index(1).help("the input file to use") @@ -216,16 +216,16 @@ impl<'help> App<'help> { self } - /// Allows one to mutate an [`Arg`] after it's been added to an [`App`]. + /// Allows one to mutate an [`Arg`] after it's been added to an [`Command`]. /// /// This can be useful for modifying the auto-generated help or version arguments. /// /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// - /// let mut app = App::new("foo") + /// let mut app = Command::new("foo") /// .arg(Arg::new("bar") /// .short('b')) /// .mut_arg("bar", |a| a.short('B')); @@ -283,8 +283,8 @@ impl<'help> App<'help> { /// of the arguments from the specified group is present at runtime. /// /// ```no_run - /// # use clap::{App, arg, ArgGroup}; - /// App::new("app") + /// # use clap::{Command, arg, ArgGroup}; + /// Command::new("app") /// .arg(arg!("--set-ver [ver] 'set the version manually'")) /// .arg(arg!("--major 'auto increase major'")) /// .arg(arg!("--minor 'auto increase minor'")) @@ -301,13 +301,13 @@ impl<'help> App<'help> { self } - /// Adds multiple [`ArgGroup`]s to the [`App`] at once. + /// Adds multiple [`ArgGroup`]s to the [`Command`] at once. /// /// # Examples /// /// ```no_run - /// # use clap::{App, arg, ArgGroup}; - /// App::new("app") + /// # use clap::{Command, arg, ArgGroup}; + /// Command::new("app") /// .arg(arg!("--set-ver [ver] 'set the version manually'")) /// .arg(arg!("--major 'auto increase major'")) /// .arg(arg!("--minor 'auto increase minor'")) @@ -337,20 +337,20 @@ impl<'help> App<'help> { /// Adds a subcommand to the list of valid possibilities. /// - /// Subcommands are effectively sub-[`App`]s, because they can contain their own arguments, - /// subcommands, version, usage, etc. They also function just like [`App`]s, in that they get + /// Subcommands are effectively sub-[`Command`]s, because they can contain their own arguments, + /// subcommands, version, usage, etc. They also function just like [`Command`]s, in that they get /// their own auto generated help, version, and usage. /// - /// A subcommand's [`App::name`] will be used for: + /// A subcommand's [`Command::name`] will be used for: /// - The argument the user passes in /// - Programmatically looking up the subcommand /// /// # Examples /// /// ```no_run - /// # use clap::{App, arg}; - /// App::new("myprog") - /// .subcommand(App::new("config") + /// # use clap::{Command, arg}; + /// Command::new("myprog") + /// .subcommand(Command::new("config") /// .about("Controls configuration features") /// .arg(arg!(" 'Required configuration file to use'"))) /// # ; @@ -367,12 +367,12 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, }; - /// # App::new("myprog") + /// # use clap::{Command, Arg, }; + /// # Command::new("myprog") /// .subcommands( vec![ - /// App::new("config").about("Controls configuration functionality") + /// Command::new("config").about("Controls configuration functionality") /// .arg(Arg::new("config_file").index(1)), - /// App::new("debug").about("Controls debug functionality")]) + /// Command::new("debug").about("Controls debug functionality")]) /// # ; /// ``` /// [`IntoIterator`]: std::iter::IntoIterator @@ -401,9 +401,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// fn app() -> App<'static> { - /// App::new("foo") + /// # use clap::{Command, Arg}; + /// fn app() -> Command<'static> { + /// Command::new("foo") /// .arg(Arg::new("bar").short('b') /// ) /// } @@ -427,8 +427,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let mut app = App::new("myprog"); + /// # use clap::{Command, ErrorKind}; + /// let mut app = Command::new("myprog"); /// let err = app.error(ErrorKind::InvalidValue, "Some failure case"); /// ``` pub fn error(&mut self, kind: ErrorKind, message: impl std::fmt::Display) -> Error { @@ -444,13 +444,13 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// let matches = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let matches = Command::new("myprog") /// // Args and options go here... /// .get_matches(); /// ``` /// [`env::args_os`]: std::env::args_os() - /// [`App::try_get_matches_from_mut`]: App::try_get_matches_from_mut() + /// [`App::try_get_matches_from_mut`]: Command::try_get_matches_from_mut() #[inline] pub fn get_matches(self) -> ArgMatches { self.get_matches_from(&mut env::args_os()) @@ -458,7 +458,7 @@ impl<'help> App<'help> { /// Parse [`env::args_os`], exiting on failure. /// - /// Like [`App::get_matches`] but doesn't consume the `App`. + /// Like [`App::get_matches`] but doesn't consume the `Command`. /// /// # Panics /// @@ -467,14 +467,14 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// let mut app = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let mut app = Command::new("myprog") /// // Args and options go here... /// ; /// let matches = app.get_matches_mut(); /// ``` /// [`env::args_os`]: std::env::args_os() - /// [`App::get_matches`]: App::get_matches() + /// [`App::get_matches`]: Command::get_matches() pub fn get_matches_mut(&mut self) -> ArgMatches { self.try_get_matches_from_mut(&mut env::args_os()) .unwrap_or_else(|e| e.exit()) @@ -494,8 +494,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// let matches = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let matches = Command::new("myprog") /// // Args and options go here... /// .try_get_matches() /// .unwrap_or_else(|e| e.exit()); @@ -517,7 +517,7 @@ impl<'help> App<'help> { /// Parse the specified arguments, exiting on failure. /// /// **NOTE:** The first argument will be parsed as the binary name unless - /// [`App::no_binary_name`] is used. + /// [`Command::no_binary_name`] is used. /// /// # Panics /// @@ -526,14 +526,14 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// let arg_vec = vec!["my_prog", "some", "args", "to", "parse"]; /// - /// let matches = App::new("myprog") + /// let matches = Command::new("myprog") /// // Args and options go here... /// .get_matches_from(arg_vec); /// ``` - /// [`App::get_matches`]: App::get_matches() + /// [`App::get_matches`]: Command::get_matches() /// [`clap::Result`]: Result /// [`Vec`]: std::vec::Vec pub fn get_matches_from(mut self, itr: I) -> ArgMatches @@ -555,7 +555,7 @@ impl<'help> App<'help> { /// perform a [`std::process::exit`] yourself. /// /// **NOTE:** The first argument will be parsed as the binary name unless - /// [`App::no_binary_name`] is used. + /// [`Command::no_binary_name`] is used. /// /// # Panics /// @@ -564,16 +564,16 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// let arg_vec = vec!["my_prog", "some", "args", "to", "parse"]; /// - /// let matches = App::new("myprog") + /// let matches = Command::new("myprog") /// // Args and options go here... /// .try_get_matches_from(arg_vec) /// .unwrap_or_else(|e| e.exit()); /// ``` - /// [`App::get_matches_from`]: App::get_matches_from() - /// [`App::try_get_matches`]: App::try_get_matches() + /// [`App::get_matches_from`]: Command::get_matches_from() + /// [`App::try_get_matches`]: Command::try_get_matches() /// [`Error::exit`]: crate::Error::exit() /// [`std::process::exit`]: std::process::exit() /// [`clap::Error`]: crate::Error @@ -592,7 +592,7 @@ impl<'help> App<'help> { /// Parse the specified arguments, returning a [`clap::Result`] on failure. /// - /// Like [`App::try_get_matches_from`] but doesn't consume the `App`. + /// Like [`App::try_get_matches_from`] but doesn't consume the `Command`. /// /// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are /// used. It will return a [`clap::Error`], where the [`kind`] is a [`ErrorKind::DisplayHelp`] @@ -600,7 +600,7 @@ impl<'help> App<'help> { /// perform a [`std::process::exit`] yourself. /// /// **NOTE:** The first argument will be parsed as the binary name unless - /// [`App::no_binary_name`] is used. + /// [`Command::no_binary_name`] is used. /// /// # Panics /// @@ -609,15 +609,15 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// let arg_vec = vec!["my_prog", "some", "args", "to", "parse"]; /// - /// let mut app = App::new("myprog"); + /// let mut app = Command::new("myprog"); /// // Args and options go here... /// let matches = app.try_get_matches_from_mut(arg_vec) /// .unwrap_or_else(|e| e.exit()); /// ``` - /// [`App::try_get_matches_from`]: App::try_get_matches_from() + /// [`App::try_get_matches_from`]: Command::try_get_matches_from() /// [`clap::Result`]: Result /// [`clap::Error`]: crate::Error /// [`kind`]: crate::Error @@ -676,13 +676,13 @@ impl<'help> App<'help> { /// Prints the short help message (`-h`) to [`io::stdout()`]. /// - /// See also [`App::print_long_help`]. + /// See also [`Command::print_long_help`]. /// /// # Examples /// /// ```rust - /// # use clap::App; - /// let mut app = App::new("myprog"); + /// # use clap::Command; + /// let mut app = Command::new("myprog"); /// app.print_help(); /// ``` /// [`io::stdout()`]: std::io::stdout() @@ -698,13 +698,13 @@ impl<'help> App<'help> { /// Prints the long help message (`--help`) to [`io::stdout()`]. /// - /// See also [`App::print_help`]. + /// See also [`Command::print_help`]. /// /// # Examples /// /// ```rust - /// # use clap::App; - /// let mut app = App::new("myprog"); + /// # use clap::Command; + /// let mut app = Command::new("myprog"); /// app.print_long_help(); /// ``` /// [`io::stdout()`]: std::io::stdout() @@ -723,14 +723,14 @@ impl<'help> App<'help> { /// Writes the short help message (`-h`) to a [`io::Write`] object. /// - /// See also [`App::write_long_help`]. + /// See also [`Command::write_long_help`]. /// /// # Examples /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// use std::io; - /// let mut app = App::new("myprog"); + /// let mut app = Command::new("myprog"); /// let mut out = io::stdout(); /// app.write_help(&mut out).expect("failed to write to stdout"); /// ``` @@ -747,14 +747,14 @@ impl<'help> App<'help> { /// Writes the long help message (`--help`) to a [`io::Write`] object. /// - /// See also [`App::write_help`]. + /// See also [`Command::write_help`]. /// /// # Examples /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// use std::io; - /// let mut app = App::new("myprog"); + /// let mut app = Command::new("myprog"); /// let mut out = io::stdout(); /// app.write_long_help(&mut out).expect("failed to write to stdout"); /// ``` @@ -771,7 +771,7 @@ impl<'help> App<'help> { /// Version message rendered as if the user ran `-V`. /// - /// See also [`App::render_long_version`]. + /// See also [`Command::render_long_version`]. /// /// ### Coloring /// @@ -780,14 +780,14 @@ impl<'help> App<'help> { /// ### Examples /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// use std::io; - /// let app = App::new("myprog"); + /// let app = Command::new("myprog"); /// println!("{}", app.render_version()); /// ``` /// [`io::Write`]: std::io::Write - /// [`-V` (short)]: App::version() - /// [`--version` (long)]: App::long_version() + /// [`-V` (short)]: Command::version() + /// [`--version` (long)]: Command::long_version() /// [ANSI escape codes]: https://en.wikipedia.org/wiki/ANSI_escape_code pub fn render_version(&self) -> String { self._render_version(false) @@ -795,7 +795,7 @@ impl<'help> App<'help> { /// Version message rendered as if the user ran `--version`. /// - /// See also [`App::render_version`]. + /// See also [`Command::render_version`]. /// /// ### Coloring /// @@ -804,14 +804,14 @@ impl<'help> App<'help> { /// ### Examples /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// use std::io; - /// let app = App::new("myprog"); + /// let app = Command::new("myprog"); /// println!("{}", app.render_long_version()); /// ``` /// [`io::Write`]: std::io::Write - /// [`-V` (short)]: App::version() - /// [`--version` (long)]: App::long_version() + /// [`-V` (short)]: Command::version() + /// [`--version` (long)]: Command::long_version() /// [ANSI escape codes]: https://en.wikipedia.org/wiki/ANSI_escape_code pub fn render_long_version(&self) -> String { self._render_version(true) @@ -822,9 +822,9 @@ impl<'help> App<'help> { /// ### Examples /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// use std::io; - /// let mut app = App::new("myprog"); + /// let mut app = Command::new("myprog"); /// println!("{}", app.render_usage()); /// ``` pub fn render_usage(&mut self) -> String { @@ -836,7 +836,7 @@ impl<'help> App<'help> { } } -/// App-wide Settings +/// Command-wide Settings /// /// These settings will apply to the top-level command and all subcommands, by default. Some /// settings can be overridden in subcommands. @@ -849,8 +849,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, arg}; + /// let m = Command::new("myprog") /// .no_binary_name(true) /// .arg(arg!( ... "commands to run")) /// .get_matches_from(vec!["command", "set"]); @@ -858,7 +858,7 @@ impl<'help> App<'help> { /// let cmds: Vec<&str> = m.values_of("cmd").unwrap().collect(); /// assert_eq!(cmds, ["command", "set"]); /// ``` - /// [`try_get_matches_from_mut`]: crate::App::try_get_matches_from_mut() + /// [`try_get_matches_from_mut`]: crate::Command::try_get_matches_from_mut() #[inline] pub fn no_binary_name(self, yes: bool) -> Self { if yes { @@ -878,8 +878,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, arg}; - /// let app = App::new("app") + /// # use clap::{Command, arg}; + /// let app = Command::new("app") /// .ignore_errors(true) /// .arg(arg!(-c --config "Sets a custom config file").required(false)) /// .arg(arg!(-x --stuff "Sets a custom stuff file").required(false)) @@ -921,7 +921,7 @@ impl<'help> App<'help> { } } - /// Disables the automatic delimiting of values after `--` or when [`App::trailing_var_arg`] + /// Disables the automatic delimiting of values after `--` or when [`Command::trailing_var_arg`] /// was used. /// /// **NOTE:** The same thing can be done manually by setting the final positional argument to @@ -933,8 +933,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .dont_delimit_trailing_values(true) /// .get_matches(); /// ``` @@ -958,8 +958,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, ColorChoice}; - /// App::new("myprog") + /// # use clap::{Command, ColorChoice}; + /// Command::new("myprog") /// .color(ColorChoice::Never) /// .get_matches(); /// ``` @@ -992,8 +992,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .term_width(80) /// # ; /// ``` @@ -1006,7 +1006,7 @@ impl<'help> App<'help> { /// Sets the maximum terminal width at which to wrap help messages. /// - /// This only applies when setting the current terminal width. See [`App::term_width`] for + /// This only applies when setting the current terminal width. See [`Command::term_width`] for /// more details. /// /// Using `0` will ignore terminal widths and use source formatting. @@ -1016,8 +1016,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .max_term_width(100) /// # ; /// ``` @@ -1033,8 +1033,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let res = App::new("myprog") + /// # use clap::{Command, ErrorKind}; + /// let res = Command::new("myprog") /// .disable_version_flag(true) /// .try_get_matches_from(vec![ /// "myprog", "-V" @@ -1063,17 +1063,17 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .version("v1.1") /// .propagate_version(true) - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .get_matches(); /// // running `$ myprog test --version` will display /// // "myprog-test v1.1" /// ``` /// - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() #[inline] pub fn propagate_version(self, yes: bool) -> Self { if yes { @@ -1090,8 +1090,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .next_line_help(true) /// .get_matches(); /// ``` @@ -1111,8 +1111,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let res = App::new("myprog") + /// # use clap::{Command, ErrorKind}; + /// let res = Command::new("myprog") /// .disable_help_flag(true) /// .try_get_matches_from(vec![ /// "myprog", "-h" @@ -1134,12 +1134,12 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let res = App::new("myprog") + /// # use clap::{Command, ErrorKind}; + /// let res = Command::new("myprog") /// .disable_help_subcommand(true) /// // Normally, creating a subcommand causes a `help` subcommand to automatically /// // be generated as well - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .try_get_matches_from(vec![ /// "myprog", "help" /// ]); @@ -1147,7 +1147,7 @@ impl<'help> App<'help> { /// assert_eq!(res.unwrap_err().kind(), ErrorKind::UnknownArgument); /// ``` /// - /// [`subcommand`]: crate::App::subcommand() + /// [`subcommand`]: crate::Command::subcommand() #[inline] pub fn disable_help_subcommand(self, yes: bool) -> Self { if yes { @@ -1164,8 +1164,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .disable_colored_help(true) /// .get_matches(); /// ``` @@ -1188,8 +1188,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .help_expected(true) /// .arg( /// Arg::new("foo").help("It does foo stuff") @@ -1201,8 +1201,8 @@ impl<'help> App<'help> { /// # Panics /// /// ```rust,no_run - /// # use clap::{App, Arg}; - /// App::new("myapp") + /// # use clap::{Command, Arg}; + /// Command::new("myapp") /// .help_expected(true) /// .arg( /// Arg::new("foo") @@ -1228,8 +1228,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .dont_collapse_args_in_usage(true) /// .get_matches(); /// ``` @@ -1270,7 +1270,7 @@ impl<'help> App<'help> { /// /// **NOTE:** This choice is propagated to all child subcommands. /// - /// [aliases]: crate::App::aliases() + /// [aliases]: crate::Command::aliases() #[inline] pub fn infer_long_args(self, yes: bool) -> Self { if yes { @@ -1291,7 +1291,7 @@ impl<'help> App<'help> { /// **CAUTION:** This setting can interfere with [positional/free arguments], take care when /// designing CLIs which allow inferred subcommands and have potential positional/free /// arguments whose values could start with the same characters as subcommands. If this is the - /// case, it's recommended to use settings such as [`App::args_conflicts_with_subcommands`] in + /// case, it's recommended to use settings such as [`Command::args_conflicts_with_subcommands`] in /// conjunction with this setting. /// /// **NOTE:** This choice is propagated to all child subcommands. @@ -1299,19 +1299,19 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// let m = App::new("prog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("prog") /// .infer_subcommands(true) - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .get_matches_from(vec![ /// "prog", "te" /// ]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` /// - /// [subcommand]: crate::App::subcommand() + /// [subcommand]: crate::Command::subcommand() /// [positional/free arguments]: crate::Arg::index() - /// [aliases]: crate::App::aliases() + /// [aliases]: crate::Command::aliases() #[inline] pub fn infer_subcommands(self, yes: bool) -> Self { if yes { @@ -1328,14 +1328,14 @@ impl<'help> App<'help> { impl<'help> App<'help> { /// (Re)Sets the program's name. /// - /// See [`App::new`] for more details. + /// See [`Command::new`] for more details. /// /// # Examples /// /// ```ignore - /// # use clap::{App, load_yaml}; + /// # use clap::{Command, load_yaml}; /// let yaml = load_yaml!("app.yaml"); - /// let app = App::from(yaml) + /// let app = Command::from(yaml) /// .name(crate_name!()); /// /// // continued logic goes here, such as `app.get_matches()` etc. @@ -1361,8 +1361,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("My Program") + /// # use clap::Command; + /// Command::new("My Program") /// .bin_name("my_binary") /// # ; /// ``` @@ -1381,8 +1381,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .author("Me, me@mymain.com") /// # ; /// ``` @@ -1395,9 +1395,9 @@ impl<'help> App<'help> { /// Sets the program's description for the short help (`-h`). /// - /// If [`App::long_about`] is not specified, this message will be displayed for `--help`. + /// If [`Command::long_about`] is not specified, this message will be displayed for `--help`. /// - /// **NOTE:** Only `App::about` (short format) is used in completion + /// **NOTE:** Only `Command::about` (short format) is used in completion /// script generation in order to be concise. /// /// See also [`crate_description!`](crate::crate_description!). @@ -1405,8 +1405,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .about("Does really amazing things for great people") /// # ; /// ``` @@ -1418,23 +1418,23 @@ impl<'help> App<'help> { /// Sets the program's description for the long help (`--help`). /// - /// If [`App::about`] is not specified, this message will be displayed for `-h`. + /// If [`Command::about`] is not specified, this message will be displayed for `-h`. /// - /// **NOTE:** Only [`App::about`] (short format) is used in completion + /// **NOTE:** Only [`Command::about`] (short format) is used in completion /// script generation in order to be concise. /// /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .long_about( /// "Does really amazing things to great people. Now let's talk a little /// more in depth about how this subcommand really works. It may take about /// a few lines of text, but that's ok!") /// # ; /// ``` - /// [`App::about`]: App::about() + /// [`App::about`]: Command::about() #[must_use] pub fn long_about>>(mut self, long_about: O) -> Self { self.long_about = long_about.into(); @@ -1446,13 +1446,13 @@ impl<'help> App<'help> { /// This is often used to describe how to use the arguments, caveats to be noted, or license /// and contact information. /// - /// If [`App::after_long_help`] is not specified, this message will be displayed for `--help`. + /// If [`Command::after_long_help`] is not specified, this message will be displayed for `--help`. /// /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .after_help("Does really amazing things for great people... but be careful with -R!") /// # ; /// ``` @@ -1468,13 +1468,13 @@ impl<'help> App<'help> { /// This is often used to describe how to use the arguments, caveats to be noted, or license /// and contact information. /// - /// If [`App::after_help`] is not specified, this message will be displayed for `-h`. + /// If [`Command::after_help`] is not specified, this message will be displayed for `-h`. /// /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .after_long_help("Does really amazing things to great people... but be careful with -R, \ /// like, for real, be careful with this!") /// # ; @@ -1489,13 +1489,13 @@ impl<'help> App<'help> { /// /// This is often used for header, copyright, or license information. /// - /// If [`App::before_long_help`] is not specified, this message will be displayed for `--help`. + /// If [`Command::before_long_help`] is not specified, this message will be displayed for `--help`. /// /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .before_help("Some info I'd like to appear before the help info") /// # ; /// ``` @@ -1509,13 +1509,13 @@ impl<'help> App<'help> { /// /// This is often used for header, copyright, or license information. /// - /// If [`App::before_help`] is not specified, this message will be displayed for `-h`. + /// If [`Command::before_help`] is not specified, this message will be displayed for `-h`. /// /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .before_long_help("Some verbose and long info I'd like to appear before the help info") /// # ; /// ``` @@ -1527,7 +1527,7 @@ impl<'help> App<'help> { /// Sets the version for the short version (`-V`) and help messages. /// - /// If [`App::long_version`] is not specified, this message will be displayed for `--version`. + /// If [`Command::long_version`] is not specified, this message will be displayed for `--version`. /// /// **Pro-tip:** Use `clap`s convenience macro [`crate_version!`] to /// automatically set your application's version to the same thing as your @@ -1536,8 +1536,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .version("v0.1.24") /// # ; /// ``` @@ -1550,7 +1550,7 @@ impl<'help> App<'help> { /// Sets the version for the long version (`--version`) and help messages. /// - /// If [`App::version`] is not specified, this message will be displayed for `-V`. + /// If [`Command::version`] is not specified, this message will be displayed for `-V`. /// /// **Pro-tip:** Use `clap`s convenience macro [`crate_version!`] to /// automatically set your application's version to the same thing as your @@ -1559,8 +1559,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .long_version( /// "v0.1.24 /// commit: abcdef89726d @@ -1585,8 +1585,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .override_usage("myapp [-clDas] ") /// # ; /// ``` @@ -1603,14 +1603,14 @@ impl<'help> App<'help> { /// /// **NOTE:** This **only** replaces the help message for the current /// command, meaning if you are using subcommands, those help messages will - /// still be auto-generated unless you specify a [`App::override_help`] for + /// still be auto-generated unless you specify a [`Command::override_help`] for /// them as well. /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myapp") + /// # use clap::{Command, Arg}; + /// Command::new("myapp") /// .override_help("myapp v1.0\n\ /// Does awesome things\n\ /// (C) me@mail.com\n\n\ @@ -1648,8 +1648,8 @@ impl<'help> App<'help> { /// * `{author}` - Author information. /// * `{author-with-newline}` - Author followed by `\n`. /// * `{author-section}` - Author preceded and followed by `\n`. - /// * `{about}` - General description (from [`App::about`] or - /// [`App::long_about`]). + /// * `{about}` - General description (from [`Command::about`] or + /// [`Command::long_about`]). /// * `{about-with-newline}` - About followed by `\n`. /// * `{about-section}` - About preceded and followed by '\n'. /// * `{usage-heading}` - Automatically generated usage heading. @@ -1659,24 +1659,24 @@ impl<'help> App<'help> { /// * `{options}` - Help for options. /// * `{positionals}` - Help for positional arguments. /// * `{subcommands}` - Help for subcommands. - /// * `{after-help}` - Help from [`App::after_help`] or [`App::after_long_help`]. - /// * `{before-help}` - Help from [`App::before_help`] or [`App::before_long_help`]. + /// * `{after-help}` - Help from [`App::after_help`] or [`Command::after_long_help`]. + /// * `{before-help}` - Help from [`App::before_help`] or [`Command::before_long_help`]. /// /// # Examples /// /// ```no_run - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .version("1.0") /// .help_template("{bin} ({version}) - {usage}") /// # ; /// ``` - /// [`App::about`]: App::about() - /// [`App::long_about`]: App::long_about() - /// [`App::after_help`]: App::after_help() - /// [`App::after_long_help`]: App::after_long_help() - /// [`App::before_help`]: App::before_help() - /// [`App::before_long_help`]: App::before_long_help() + /// [`App::about`]: Command::about() + /// [`App::long_about`]: Command::long_about() + /// [`App::after_help`]: Command::after_help() + /// [`App::after_long_help`]: Command::after_long_help() + /// [`App::before_help`]: Command::before_help() + /// [`App::before_long_help`]: Command::before_long_help() #[must_use] pub fn help_template>(mut self, s: S) -> Self { self.template = Some(s.into()); @@ -1685,23 +1685,23 @@ impl<'help> App<'help> { /// Apply a setting for the current command or subcommand. /// - /// See [`App::global_setting`] to apply a setting to this command and all subcommands. + /// See [`Command::global_setting`] to apply a setting to this command and all subcommands. /// /// See [`AppSettings`] for a full list of possibilities and examples. /// /// # Examples /// /// ```no_run - /// # use clap::{App, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// Command::new("myprog") /// .setting(AppSettings::SubcommandRequired) /// .setting(AppSettings::AllowLeadingHyphen) /// # ; /// ``` /// or /// ```no_run - /// # use clap::{App, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// Command::new("myprog") /// .setting(AppSettings::SubcommandRequired | AppSettings::AllowLeadingHyphen) /// # ; /// ``` @@ -1722,16 +1722,16 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// Command::new("myprog") /// .unset_setting(AppSettings::SubcommandRequired) /// .setting(AppSettings::AllowLeadingHyphen) /// # ; /// ``` /// or /// ```no_run - /// # use clap::{App, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// Command::new("myprog") /// .unset_setting(AppSettings::SubcommandRequired | AppSettings::AllowLeadingHyphen) /// # ; /// ``` @@ -1747,15 +1747,15 @@ impl<'help> App<'help> { /// Apply a setting for the current command and all subcommands. /// - /// See [`App::setting`] to apply a setting only to this command. + /// See [`Command::setting`] to apply a setting only to this command. /// /// See [`AppSettings`] for a full list of possibilities and examples. /// /// # Examples /// /// ```no_run - /// # use clap::{App, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// Command::new("myprog") /// .global_setting(AppSettings::AllowNegativeNumbers) /// # ; /// ``` @@ -1774,12 +1774,12 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, AppSettings}; - /// App::new("myprog") + /// # use clap::{Command, AppSettings}; + /// Command::new("myprog") /// .unset_global_setting(AppSettings::AllowNegativeNumbers) /// # ; /// ``` - /// [global]: App::global_setting() + /// [global]: Command::global_setting() #[inline] #[must_use] pub fn unset_global_setting(mut self, setting: AppSettings) -> Self { @@ -1788,7 +1788,7 @@ impl<'help> App<'help> { self } - /// Deprecated, replaced with [`App::next_help_heading`] + /// Deprecated, replaced with [`Command::next_help_heading`] #[inline] #[must_use] #[deprecated(since = "3.1.0", note = "Replaced with `App::next_help_heading`")] @@ -1806,9 +1806,9 @@ impl<'help> App<'help> { /// This is useful if the default `OPTIONS` or `ARGS` headings are /// not specific enough for one's use case. /// - /// For subcommands, see [`App::subcommand_help_heading`] + /// For subcommands, see [`Command::subcommand_help_heading`] /// - /// [`App::arg`]: App::arg() + /// [`App::arg`]: Command::arg() /// [`Arg::help_heading`]: crate::Arg::help_heading() #[inline] #[must_use] @@ -1856,15 +1856,15 @@ impl<'help> App<'help> { /// dispatch to `app module install` handling code. This is error prone and /// tedious. /// - /// We could instead use [`App::replace`] so that, when the user types `app + /// We could instead use [`Command::replace`] so that, when the user types `app /// install`, `clap` will replace `install` with `module install` which will /// end up getting parsed as if the user typed the entire incantation. /// /// ```rust - /// # use clap::App; - /// let m = App::new("app") - /// .subcommand(App::new("module") - /// .subcommand(App::new("install"))) + /// # use clap::Command; + /// let m = Command::new("app") + /// .subcommand(Command::new("module") + /// .subcommand(Command::new("install"))) /// .replace("install", &["module", "install"]) /// .get_matches_from(vec!["app", "install"]); /// @@ -1887,15 +1887,15 @@ impl<'help> App<'help> { /// and we forgot to update that code to *also* check `--save-all` it'd mean /// an error! /// - /// Luckily we can use [`App::replace`] so that when the user types + /// Luckily we can use [`Command::replace`] so that when the user types /// `--save-all`, `clap` will replace that argument with `--save-context /// --save-runtime`, and parsing will continue like normal. Now all our code /// that was originally checking for things like `--save-context` doesn't /// need to change! /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("app") + /// # use clap::{Command, Arg}; + /// let m = Command::new("app") /// .arg(Arg::new("save-context") /// .long("save-context")) /// .arg(Arg::new("save-runtime") @@ -1914,8 +1914,8 @@ impl<'help> App<'help> { /// above to enforce this: /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("app") + /// # use clap::{Command, Arg}; + /// let m = Command::new("app") /// .arg(Arg::new("save-context") /// .long("save-context")) /// .arg(Arg::new("save-runtime") @@ -1932,7 +1932,7 @@ impl<'help> App<'help> { /// assert_eq!(m.value_of("format"), Some("json")); /// ``` /// - /// [`App::replace`]: App::replace() + /// [`App::replace`]: Command::replace() #[inline] #[cfg(feature = "unstable-replace")] #[must_use] @@ -1948,12 +1948,12 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App}; - /// App::new("myprog") + /// # use clap::{Command}; + /// Command::new("myprog") /// .arg_required_else_help(true); /// ``` /// - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() /// [`Arg::default_value`]: crate::Arg::default_value() #[inline] pub fn arg_required_else_help(self, yes: bool) -> Self { @@ -1967,7 +1967,7 @@ impl<'help> App<'help> { /// Specifies that leading hyphens are allowed in all argument *values* (e.g. `-10`). /// /// Otherwise they will be parsed as another flag or option. See also - /// [`App::allow_negative_numbers`]. + /// [`Command::allow_negative_numbers`]. /// /// **NOTE:** Use this setting with caution as it silences certain circumstances which would /// otherwise be an error (such as accidentally forgetting to specify a value for leading @@ -1976,9 +1976,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{Arg, App}; + /// # use clap::{Arg, Command}; /// // Imagine you needed to represent negative numbers as well, such as -10 - /// let m = App::new("nums") + /// let m = Command::new("nums") /// .allow_hyphen_values(true) /// .arg(Arg::new("neg")) /// .get_matches_from(vec![ @@ -2000,14 +2000,14 @@ impl<'help> App<'help> { /// Allows negative numbers to pass as values. /// - /// This is similar to [`App::allow_hyphen_values`] except that it only allows numbers, + /// This is similar to [`Command::allow_hyphen_values`] except that it only allows numbers, /// all other undefined leading hyphens will fail to parse. /// /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let res = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let res = Command::new("myprog") /// .allow_negative_numbers(true) /// .arg(Arg::new("num")) /// .try_get_matches_from(vec![ @@ -2037,8 +2037,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, arg}; + /// let m = Command::new("myprog") /// .trailing_var_arg(true) /// .arg(arg!( ... "commands to run")) /// .get_matches_from(vec!["myprog", "arg1", "-r", "val1"]); @@ -2089,9 +2089,9 @@ impl<'help> App<'help> { /// Style number one from above: /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// // Assume there is an external subcommand named "subcmd" - /// let m = App::new("myprog") + /// let m = Command::new("myprog") /// .allow_missing_positional(true) /// .arg(Arg::new("arg1")) /// .arg(Arg::new("arg2") @@ -2107,9 +2107,9 @@ impl<'help> App<'help> { /// Now the same example, but using a default value for the first optional positional argument /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// // Assume there is an external subcommand named "subcmd" - /// let m = App::new("myprog") + /// let m = Command::new("myprog") /// .allow_missing_positional(true) /// .arg(Arg::new("arg1") /// .default_value("something")) @@ -2126,9 +2126,9 @@ impl<'help> App<'help> { /// Style number two from above: /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// // Assume there is an external subcommand named "subcmd" - /// let m = App::new("myprog") + /// let m = Command::new("myprog") /// .allow_missing_positional(true) /// .arg(Arg::new("foo")) /// .arg(Arg::new("bar")) @@ -2145,9 +2145,9 @@ impl<'help> App<'help> { /// Now nofice if we don't specify `foo` or `baz` but use the `--` operator. /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{Command, Arg}; /// // Assume there is an external subcommand named "subcmd" - /// let m = App::new("myprog") + /// let m = Command::new("myprog") /// .allow_missing_positional(true) /// .arg(Arg::new("foo")) /// .arg(Arg::new("bar")) @@ -2181,10 +2181,10 @@ impl<'help> App<'help> { /// # Examples /// /// ``` - /// # use clap::{App, Arg}; - /// let matches = App::new("pacman") + /// # use clap::{Command, Arg}; + /// let matches = Command::new("pacman") /// .subcommand( - /// App::new("sync").short_flag('S').arg( + /// Command::new("sync").short_flag('S').arg( /// Arg::new("search") /// .short('s') /// .long("search") @@ -2217,10 +2217,10 @@ impl<'help> App<'help> { /// will *not* be stripped (i.e. `sync-file` is allowed). /// /// ``` - /// # use clap::{App, Arg}; - /// let matches = App::new("pacman") + /// # use clap::{Command, Arg}; + /// let matches = Command::new("pacman") /// .subcommand( - /// App::new("sync").long_flag("sync").arg( + /// Command::new("sync").long_flag("sync").arg( /// Arg::new("search") /// .short('s') /// .long("search") @@ -2249,7 +2249,7 @@ impl<'help> App<'help> { /// /// **NOTE:** Aliases defined with this method are *hidden* from the help /// message. If you're looking for aliases that will be displayed in the help - /// message, see [`App::visible_alias`]. + /// message, see [`Command::visible_alias`]. /// /// **NOTE:** When using aliases and checking for the existence of a /// particular subcommand within an [`ArgMatches`] struct, one only needs to @@ -2258,14 +2258,14 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test") + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test") /// .alias("do-stuff")) /// .get_matches_from(vec!["myprog", "do-stuff"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::visible_alias`]: App::visible_alias() + /// [`App::visible_alias`]: Command::visible_alias() #[must_use] pub fn alias>(mut self, name: S) -> Self { self.aliases.push((name.into(), false)); @@ -2281,9 +2281,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").short_flag('t') + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").short_flag('t') /// .short_flag_alias('d')) /// .get_matches_from(vec!["myprog", "-d"]); /// assert_eq!(m.subcommand_name(), Some("test")); @@ -2304,9 +2304,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").long_flag("test") + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").long_flag("test") /// .long_flag_alias("testing")) /// .get_matches_from(vec!["myprog", "--testing"]); /// assert_eq!(m.subcommand_name(), Some("test")); @@ -2325,7 +2325,7 @@ impl<'help> App<'help> { /// /// **NOTE:** Aliases defined with this method are *hidden* from the help /// message. If looking for aliases that will be displayed in the help - /// message, see [`App::visible_aliases`]. + /// message, see [`Command::visible_aliases`]. /// /// **NOTE:** When using aliases and checking for the existence of a /// particular subcommand within an [`ArgMatches`] struct, one only needs to @@ -2334,9 +2334,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") - /// .subcommand(App::new("test") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test") /// .aliases(&["do-stuff", "do-tests", "tests"])) /// .arg(Arg::new("input") /// .help("the file to add") @@ -2345,7 +2345,7 @@ impl<'help> App<'help> { /// .get_matches_from(vec!["myprog", "do-tests"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::visible_aliases`]: App::visible_aliases() + /// [`App::visible_aliases`]: Command::visible_aliases() #[must_use] pub fn aliases(mut self, names: &[&'help str]) -> Self { self.aliases.extend(names.iter().map(|n| (*n, false))); @@ -2361,9 +2361,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").short_flag('t') + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").short_flag('t') /// .short_flag_aliases(&['a', 'b', 'c'])) /// .arg(Arg::new("input") /// .help("the file to add") @@ -2390,9 +2390,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").long_flag("test") + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").long_flag("test") /// .long_flag_aliases(&["testing", "testall", "test_all"])) /// .arg(Arg::new("input") /// .help("the file to add") @@ -2419,7 +2419,7 @@ impl<'help> App<'help> { /// **NOTE:** The alias defined with this method is *visible* from the help /// message and displayed as if it were just another regular subcommand. If /// looking for an alias that will not be displayed in the help message, see - /// [`App::alias`]. + /// [`Command::alias`]. /// /// **NOTE:** When using aliases and checking for the existence of a /// particular subcommand within an [`ArgMatches`] struct, one only needs to @@ -2428,14 +2428,14 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") - /// .subcommand(App::new("test") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test") /// .visible_alias("do-stuff")) /// .get_matches_from(vec!["myprog", "do-stuff"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::alias`]: App::alias() + /// [`App::alias`]: Command::alias() #[must_use] pub fn visible_alias>(mut self, name: S) -> Self { self.aliases.push((name.into(), true)); @@ -2448,19 +2448,19 @@ impl<'help> App<'help> { /// and easier than creating multiple hidden subcommands as one only needs to check for the /// existence of this command, and not all variants. /// - /// See also [`App::short_flag_alias`]. + /// See also [`Command::short_flag_alias`]. /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").short_flag('t') + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").short_flag('t') /// .visible_short_flag_alias('d')) /// .get_matches_from(vec!["myprog", "-d"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::short_flag_alias`]: App::short_flag_alias() + /// [`App::short_flag_alias`]: Command::short_flag_alias() #[must_use] pub fn visible_short_flag_alias(mut self, name: char) -> Self { assert!(name != '-', "short alias name cannot be `-`"); @@ -2474,19 +2474,19 @@ impl<'help> App<'help> { /// and easier than creating multiple hidden subcommands as one only needs to check for the /// existence of this command, and not all variants. /// - /// See also [`App::long_flag_alias`]. + /// See also [`Command::long_flag_alias`]. /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").long_flag("test") + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").long_flag("test") /// .visible_long_flag_alias("testing")) /// .get_matches_from(vec!["myprog", "--testing"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::long_flag_alias`]: App::long_flag_alias() + /// [`App::long_flag_alias`]: Command::long_flag_alias() #[must_use] pub fn visible_long_flag_alias(mut self, name: &'help str) -> Self { self.long_flag_aliases.push((name, true)); @@ -2503,7 +2503,7 @@ impl<'help> App<'help> { /// **NOTE:** The alias defined with this method is *visible* from the help /// message and displayed as if it were just another regular subcommand. If /// looking for an alias that will not be displayed in the help message, see - /// [`App::alias`]. + /// [`Command::alias`]. /// /// **NOTE:** When using aliases, and checking for the existence of a /// particular subcommand within an [`ArgMatches`] struct, one only needs to @@ -2512,14 +2512,14 @@ impl<'help> App<'help> { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test") + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test") /// .visible_aliases(&["do-stuff", "tests"])) /// .get_matches_from(vec!["myprog", "do-stuff"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::alias`]: App::alias() + /// [`App::alias`]: Command::alias() #[must_use] pub fn visible_aliases(mut self, names: &[&'help str]) -> Self { self.aliases.extend(names.iter().map(|n| (*n, true))); @@ -2528,19 +2528,19 @@ impl<'help> App<'help> { /// Add aliases, which function as *visible* short flag subcommands. /// - /// See [`App::short_flag_aliases`]. + /// See [`Command::short_flag_aliases`]. /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").short_flag('b') + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").short_flag('b') /// .visible_short_flag_aliases(&['t'])) /// .get_matches_from(vec!["myprog", "-t"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::short_flag_aliases`]: App::short_flag_aliases() + /// [`App::short_flag_aliases`]: Command::short_flag_aliases() #[must_use] pub fn visible_short_flag_aliases(mut self, names: &[char]) -> Self { for s in names { @@ -2552,19 +2552,19 @@ impl<'help> App<'help> { /// Add aliases, which function as *visible* long flag subcommands. /// - /// See [`App::long_flag_aliases`]. + /// See [`Command::long_flag_aliases`]. /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let m = App::new("myprog") - /// .subcommand(App::new("test").long_flag("test") + /// # use clap::{Command, Arg, }; + /// let m = Command::new("myprog") + /// .subcommand(Command::new("test").long_flag("test") /// .visible_long_flag_aliases(&["testing", "testall", "test_all"])) /// .get_matches_from(vec!["myprog", "--testing"]); /// assert_eq!(m.subcommand_name(), Some("test")); /// ``` - /// [`App::long_flag_aliases`]: App::long_flag_aliases() + /// [`App::long_flag_aliases`]: Command::long_flag_aliases() #[must_use] pub fn visible_long_flag_aliases(mut self, names: &[&'help str]) -> Self { for s in names { @@ -2586,15 +2586,15 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, }; - /// let m = App::new("cust-ord") - /// .subcommand(App::new("alpha") // typically subcommands are grouped + /// # use clap::{Command, }; + /// let m = Command::new("cust-ord") + /// .subcommand(Command::new("alpha") // typically subcommands are grouped /// // alphabetically by name. Subcommands /// // without a display_order have a value of /// // 999 and are displayed alphabetically with /// // all other 999 subcommands /// .about("Some help and text")) - /// .subcommand(App::new("beta") + /// .subcommand(Command::new("beta") /// .display_order(1) // In order to force this subcommand to appear *first* /// // all we have to do is give it a value lower than 999. /// // Any other subcommands with a value of 1 will be displayed @@ -2633,15 +2633,15 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// App::new("myprog") + /// # use clap::{Command, Arg}; + /// Command::new("myprog") /// .subcommand( - /// App::new("test").hide(true) + /// Command::new("test").hide(true) /// ) /// # ; /// ``` /// - /// [`subcommand`]: crate::App::subcommand() + /// [`subcommand`]: crate::Command::subcommand() #[inline] pub fn hide(self, yes: bool) -> Self { if yes { @@ -2656,10 +2656,10 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let err = App::new("myprog") + /// # use clap::{Command, ErrorKind}; + /// let err = Command::new("myprog") /// .subcommand_required(true) - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .try_get_matches_from(vec![ /// "myprog", /// ]); @@ -2668,7 +2668,7 @@ impl<'help> App<'help> { /// # ; /// ``` /// - /// [`subcommand`]: crate::App::subcommand() + /// [`subcommand`]: crate::Command::subcommand() pub fn subcommand_required(self, yes: bool) -> Self { if yes { self.setting(AppSettings::SubcommandRequired) @@ -2687,9 +2687,9 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// // Assume there is an external subcommand named "subcmd" - /// let m = App::new("myprog") + /// let m = Command::new("myprog") /// .allow_external_subcommands(true) /// .get_matches_from(vec![ /// "myprog", "subcmd", "--option", "value", "-fff", "--flag" @@ -2707,7 +2707,7 @@ impl<'help> App<'help> { /// } /// ``` /// - /// [`subcommand`]: crate::App::subcommand() + /// [`subcommand`]: crate::Command::subcommand() /// [`ArgMatches`]: crate::ArgMatches /// [`ErrorKind::UnknownArgument`]: crate::ErrorKind::UnknownArgument pub fn allow_external_subcommands(self, yes: bool) -> Self { @@ -2724,7 +2724,7 @@ impl<'help> App<'help> { /// [`ArgMatches::values_of_os`] or [`ArgMatches::values_of_lossy`] for those particular /// arguments which may contain invalid UTF-8 values /// - /// **NOTE:** Setting this requires [`App::allow_external_subcommands`] + /// **NOTE:** Setting this requires [`Command::allow_external_subcommands`] /// /// # Platform Specific /// @@ -2734,9 +2734,9 @@ impl<'help> App<'help> { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::App; + /// # use clap::Command; /// // Assume there is an external subcommand named "subcmd" - /// let m = App::new("myprog") + /// let m = Command::new("myprog") /// .allow_invalid_utf8_for_external_subcommands(true) /// .allow_external_subcommands(true) /// .get_matches_from(vec![ @@ -2757,7 +2757,7 @@ impl<'help> App<'help> { /// /// [`ArgMatches::values_of_os`]: crate::ArgMatches::values_of_os() /// [`ArgMatches::values_of_lossy`]: crate::ArgMatches::values_of_lossy() - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() pub fn allow_invalid_utf8_for_external_subcommands(self, yes: bool) -> Self { if yes { self.setting(AppSettings::AllowInvalidUtf8ForExternalSubcommands) @@ -2782,12 +2782,12 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::App; - /// App::new("myprog") + /// # use clap::Command; + /// Command::new("myprog") /// .args_conflicts_with_subcommands(true); /// ``` /// - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() pub fn args_conflicts_with_subcommands(self, yes: bool) -> Self { if yes { self.setting(AppSettings::ArgsNegateSubcommands) @@ -2822,8 +2822,8 @@ impl<'help> App<'help> { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let app = App::new("app").subcommand(App::new("sub")).arg( + /// # use clap::{Command, Arg}; + /// let app = Command::new("app").subcommand(Command::new("sub")).arg( /// Arg::new("arg") /// .long("arg") /// .multiple_values(true) @@ -2872,11 +2872,11 @@ impl<'help> App<'help> { /// This first example shows that it is an error to not use a required argument /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let err = App::new("myprog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let err = Command::new("myprog") /// .subcommand_negates_reqs(true) /// .arg(Arg::new("opt").required(true)) - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .try_get_matches_from(vec![ /// "myprog" /// ]); @@ -2889,11 +2889,11 @@ impl<'help> App<'help> { /// valid subcommand is used. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let noerr = App::new("myprog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let noerr = Command::new("myprog") /// .subcommand_negates_reqs(true) /// .arg(Arg::new("opt").required(true)) - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .try_get_matches_from(vec![ /// "myprog", "test" /// ]); @@ -2902,7 +2902,7 @@ impl<'help> App<'help> { /// ``` /// /// [`Arg::required(true)`]: crate::Arg::required() - /// [`subcommands`]: crate::App::subcommand() + /// [`subcommands`]: crate::Command::subcommand() pub fn subcommand_negates_reqs(self, yes: bool) -> Self { if yes { self.setting(AppSettings::SubcommandsNegateReqs) @@ -2940,18 +2940,18 @@ impl<'help> App<'help> { /// The name of the app is essentially unused /// and may be the same as the name of a subcommand. /// - /// The names of the immediate subcommands of the App + /// The names of the immediate subcommands of the Command /// are matched against the basename of the first argument, /// which is conventionally the path of the executable. /// /// This does not allow the subcommand to be passed as the first non-path argument. /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let mut app = App::new("hostname") + /// # use clap::{Command, ErrorKind}; + /// let mut app = Command::new("hostname") /// .multicall(true) - /// .subcommand(App::new("hostname")) - /// .subcommand(App::new("dnsdomainname")); + /// .subcommand(Command::new("hostname")) + /// .subcommand(Command::new("dnsdomainname")); /// let m = app.try_get_matches_from_mut(&["/usr/bin/hostname", "dnsdomainname"]); /// assert!(m.is_err()); /// assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); @@ -2970,18 +2970,18 @@ impl<'help> App<'help> { /// or there may already be a command of that name installed. /// /// To make an applet usable as both a multicall link and a subcommand - /// the subcommands must be defined both in the top-level App + /// the subcommands must be defined both in the top-level Command /// and as subcommands of the "main" applet. /// /// ```rust - /// # use clap::App; - /// fn applet_commands() -> [App<'static>; 2] { - /// [App::new("true"), App::new("false")] + /// # use clap::Command; + /// fn applet_commands() -> [Command<'static>; 2] { + /// [Command::new("true"), Command::new("false")] /// } - /// let mut app = App::new("busybox") + /// let mut app = Command::new("busybox") /// .multicall(true) /// .subcommand( - /// App::new("busybox") + /// Command::new("busybox") /// .subcommand_value_name("APPLET") /// .subcommand_help_heading("APPLETS") /// .subcommands(applet_commands()), @@ -2998,12 +2998,12 @@ impl<'help> App<'help> { /// ``` /// /// **NOTE:** Applets are slightly semantically different from subcommands, - /// so it's recommended to use [`App::subcommand_help_heading`] and - /// [`App::subcommand_value_name`] to change the descriptive text as above. + /// so it's recommended to use [`Command::subcommand_help_heading`] and + /// [`Command::subcommand_value_name`] to change the descriptive text as above. /// - /// [`no_binary_name`]: crate::App::no_binary_name - /// [`App::subcommand_value_name`]: crate::App::subcommand_value_name - /// [`App::subcommand_help_heading`]: crate::App::subcommand_help_heading + /// [`no_binary_name`]: crate::Command::no_binary_name + /// [`App::subcommand_value_name`]: crate::Command::subcommand_value_name + /// [`App::subcommand_help_heading`]: crate::Command::subcommand_help_heading #[inline] #[cfg(feature = "unstable-multicall")] pub fn multicall(self, yes: bool) -> Self { @@ -3018,14 +3018,14 @@ impl<'help> App<'help> { /// /// By default, this is "SUBCOMMAND". /// - /// See also [`App::subcommand_help_heading`] + /// See also [`Command::subcommand_help_heading`] /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") - /// .subcommand(App::new("sub1")) + /// # use clap::{Command, Arg}; + /// Command::new("myprog") + /// .subcommand(Command::new("sub1")) /// .print_help() /// # ; /// ``` @@ -3050,9 +3050,9 @@ impl<'help> App<'help> { /// but usage of `subcommand_value_name` /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") - /// .subcommand(App::new("sub1")) + /// # use clap::{Command, Arg}; + /// Command::new("myprog") + /// .subcommand(Command::new("sub1")) /// .subcommand_value_name("THING") /// .print_help() /// # ; @@ -3087,14 +3087,14 @@ impl<'help> App<'help> { /// /// By default, this is "SUBCOMMANDS". /// - /// See also [`App::subcommand_value_name`] + /// See also [`Command::subcommand_value_name`] /// /// # Examples /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") - /// .subcommand(App::new("sub1")) + /// # use clap::{Command, Arg}; + /// Command::new("myprog") + /// .subcommand(Command::new("sub1")) /// .print_help() /// # ; /// ``` @@ -3119,9 +3119,9 @@ impl<'help> App<'help> { /// but usage of `subcommand_help_heading` /// /// ```no_run - /// # use clap::{App, Arg}; - /// App::new("myprog") - /// .subcommand(App::new("sub1")) + /// # use clap::{Command, Arg}; + /// Command::new("myprog") + /// .subcommand(Command::new("sub1")) /// .subcommand_help_heading("THINGS") /// .print_help() /// # ; @@ -3207,32 +3207,32 @@ impl<'help> App<'help> { self.long_flag } - /// Get the help message specified via [`App::about`]. + /// Get the help message specified via [`Command::about`]. /// - /// [`App::about`]: App::about() + /// [`App::about`]: Command::about() #[inline] pub fn get_about(&self) -> Option<&'help str> { self.about } - /// Get the help message specified via [`App::long_about`]. + /// Get the help message specified via [`Command::long_about`]. /// - /// [`App::long_about`]: App::long_about() + /// [`App::long_about`]: Command::long_about() #[inline] pub fn get_long_about(&self) -> Option<&'help str> { self.long_about } - /// Deprecated, replaced with [`App::get_next_help_heading`] + /// Deprecated, replaced with [`Command::get_next_help_heading`] #[inline] #[deprecated(since = "3.1.0", note = "Replaced with `App::get_next_help_heading`")] pub fn get_help_heading(&self) -> Option<&'help str> { self.get_next_help_heading() } - /// Get the custom section heading specified via [`App::help_heading`]. + /// Get the custom section heading specified via [`Command::help_heading`]. /// - /// [`App::help_heading`]: App::help_heading() + /// [`App::help_heading`]: Command::help_heading() #[inline] pub fn get_next_help_heading(&self) -> Option<&'help str> { self.current_help_heading @@ -3280,12 +3280,12 @@ impl<'help> App<'help> { self.long_flag_aliases.iter().map(|a| a.0) } - /// Check if the given [`AppSettings`] variant is currently set on the `App`. + /// Check if the given [`AppSettings`] variant is currently set on the `Command`. /// /// This checks both [local] and [global settings]. /// - /// [local]: App::setting() - /// [global settings]: App::global_setting() + /// [local]: Command::setting() + /// [global settings]: Command::global_setting() #[inline] pub fn is_set(&self, s: AppSettings) -> bool { self.settings.is_set(s) || self.g_settings.is_set(s) @@ -3325,7 +3325,7 @@ impl<'help> App<'help> { self.subcommands.iter_mut() } - /// Returns `true` if this `App` has subcommands. + /// Returns `true` if this `Command` has subcommands. #[inline] pub fn has_subcommands(&self) -> bool { !self.subcommands.is_empty() @@ -3432,7 +3432,7 @@ impl<'help> App<'help> { /// ### Panics /// /// If the given arg contains a conflict with an argument that is unknown to - /// this `App`. + /// this `Command`. pub fn get_arg_conflicts_with(&self, arg: &Arg) -> Vec<&Arg<'help>> // FIXME: This could probably have been an iterator { if arg.is_global_set() { @@ -3504,134 +3504,134 @@ impl<'help> App<'help> { vec } - /// Report whether [`App::no_binary_name`] is set + /// Report whether [`Command::no_binary_name`] is set #[allow(unused)] pub(crate) fn is_no_binary_name_set(&self) -> bool { self.is_set(AppSettings::NoBinaryName) } - /// Report whether [`App::ignore_errors`] is set + /// Report whether [`Command::ignore_errors`] is set pub(crate) fn is_ignore_errors_set(&self) -> bool { self.is_set(AppSettings::IgnoreErrors) } - /// Report whether [`App::dont_delimit_trailing_values`] is set + /// Report whether [`Command::dont_delimit_trailing_values`] is set pub fn is_dont_delimit_trailing_values_set(&self) -> bool { self.is_set(AppSettings::DontDelimitTrailingValues) } - /// Report whether [`App::disable_version_flag`] is set + /// Report whether [`Command::disable_version_flag`] is set pub fn is_disable_version_flag_set(&self) -> bool { self.is_set(AppSettings::DisableVersionFlag) } - /// Report whether [`App::propagate_version`] is set + /// Report whether [`Command::propagate_version`] is set pub fn is_propagate_version_set(&self) -> bool { self.is_set(AppSettings::PropagateVersion) } - /// Report whether [`App::next_line_help`] is set + /// Report whether [`Command::next_line_help`] is set pub fn is_next_line_help_set(&self) -> bool { self.is_set(AppSettings::NextLineHelp) } - /// Report whether [`App::disable_help_flag`] is set + /// Report whether [`Command::disable_help_flag`] is set pub fn is_disable_help_flag_set(&self) -> bool { self.is_set(AppSettings::DisableHelpFlag) } - /// Report whether [`App::disable_help_subcommand`] is set + /// Report whether [`Command::disable_help_subcommand`] is set pub fn is_disable_help_subcommand_set(&self) -> bool { self.is_set(AppSettings::DisableHelpSubcommand) } - /// Report whether [`App::disable_colored_help`] is set + /// Report whether [`Command::disable_colored_help`] is set pub fn is_disable_colored_help_set(&self) -> bool { self.is_set(AppSettings::DisableColoredHelp) } - /// Report whether [`App::help_expected`] is set + /// Report whether [`Command::help_expected`] is set #[cfg(debug_assertions)] pub(crate) fn is_help_expected_set(&self) -> bool { self.is_set(AppSettings::HelpExpected) } - /// Report whether [`App::dont_collapse_args_in_usage`] is set + /// Report whether [`Command::dont_collapse_args_in_usage`] is set pub fn is_dont_collapse_args_in_usage_set(&self) -> bool { self.is_set(AppSettings::DontCollapseArgsInUsage) } - /// Report whether [`App::infer_long_args`] is set + /// Report whether [`Command::infer_long_args`] is set pub(crate) fn is_infer_long_args_set(&self) -> bool { self.is_set(AppSettings::InferLongArgs) } - /// Report whether [`App::infer_subcommands`] is set + /// Report whether [`Command::infer_subcommands`] is set pub(crate) fn is_infer_subcommands_set(&self) -> bool { self.is_set(AppSettings::InferSubcommands) } - /// Report whether [`App::arg_required_else_help`] is set + /// Report whether [`Command::arg_required_else_help`] is set pub fn is_arg_required_else_help_set(&self) -> bool { self.is_set(AppSettings::ArgRequiredElseHelp) } - /// Report whether [`App::allow_hyphen_values`] is set + /// Report whether [`Command::allow_hyphen_values`] is set pub(crate) fn is_allow_hyphen_values_set(&self) -> bool { self.is_set(AppSettings::AllowHyphenValues) } - /// Report whether [`App::allow_negative_numbers`] is set + /// Report whether [`Command::allow_negative_numbers`] is set pub fn is_allow_negative_numbers_set(&self) -> bool { self.is_set(AppSettings::AllowNegativeNumbers) } - /// Report whether [`App::trailing_var_arg`] is set + /// Report whether [`Command::trailing_var_arg`] is set pub fn is_trailing_var_arg_set(&self) -> bool { self.is_set(AppSettings::TrailingVarArg) } - /// Report whether [`App::allow_missing_positional`] is set + /// Report whether [`Command::allow_missing_positional`] is set pub fn is_allow_missing_positional_set(&self) -> bool { self.is_set(AppSettings::AllowMissingPositional) } - /// Report whether [`App::hide`] is set + /// Report whether [`Command::hide`] is set pub fn is_hide_set(&self) -> bool { self.is_set(AppSettings::Hidden) } - /// Report whether [`App::subcommand_required`] is set + /// Report whether [`Command::subcommand_required`] is set pub fn is_subcommand_required_set(&self) -> bool { self.is_set(AppSettings::SubcommandRequired) } - /// Report whether [`App::allow_external_subcommands`] is set + /// Report whether [`Command::allow_external_subcommands`] is set pub fn is_allow_external_subcommands_set(&self) -> bool { self.is_set(AppSettings::AllowExternalSubcommands) } - /// Report whether [`App::allow_invalid_utf8_for_external_subcommands`] is set + /// Report whether [`Command::allow_invalid_utf8_for_external_subcommands`] is set pub fn is_allow_invalid_utf8_for_external_subcommands_set(&self) -> bool { self.is_set(AppSettings::AllowInvalidUtf8ForExternalSubcommands) } - /// Report whether [`App::args_conflicts_with_subcommands`] is set + /// Report whether [`Command::args_conflicts_with_subcommands`] is set pub fn is_args_conflicts_with_subcommands_set(&self) -> bool { self.is_set(AppSettings::ArgsNegateSubcommands) } - /// Report whether [`App::subcommand_precedence_over_arg`] is set + /// Report whether [`Command::subcommand_precedence_over_arg`] is set pub fn is_subcommand_precedence_over_arg_set(&self) -> bool { self.is_set(AppSettings::SubcommandPrecedenceOverArg) } - /// Report whether [`App::subcommand_negates_reqs`] is set + /// Report whether [`Command::subcommand_negates_reqs`] is set pub fn is_subcommand_negates_reqs_set(&self) -> bool { self.is_set(AppSettings::SubcommandsNegateReqs) } - /// Report whether [`App::multicall`] is set + /// Report whether [`Command::multicall`] is set #[cfg(feature = "unstable-multicall")] pub fn is_multicall_set(&self) -> bool { self.is_set(AppSettings::Multicall) @@ -3732,7 +3732,7 @@ impl<'help> App<'help> { a } - /// Deprecated, replaced with [`App::override_usage`] + /// Deprecated, replaced with [`Command::override_usage`] #[deprecated(since = "3.0.0", note = "Replaced with `App::override_usage`")] #[doc(hidden)] #[must_use] @@ -3740,7 +3740,7 @@ impl<'help> App<'help> { self.override_usage(usage) } - /// Deprecated, replaced with [`App::override_help`] + /// Deprecated, replaced with [`Command::override_help`] #[deprecated(since = "3.0.0", note = "Replaced with `App::override_help`")] #[doc(hidden)] #[must_use] @@ -3748,7 +3748,7 @@ impl<'help> App<'help> { self.override_help(help) } - /// Deprecated, replaced with [`App::mut_arg`] + /// Deprecated, replaced with [`Command::mut_arg`] #[deprecated(since = "3.0.0", note = "Replaced with `App::mut_arg`")] #[doc(hidden)] #[must_use] @@ -3756,7 +3756,7 @@ impl<'help> App<'help> { self.mut_arg("help", |a| a.short(c)) } - /// Deprecated, replaced with [`App::mut_arg`] + /// Deprecated, replaced with [`Command::mut_arg`] #[deprecated(since = "3.0.0", note = "Replaced with `App::mut_arg`")] #[doc(hidden)] #[must_use] @@ -3764,7 +3764,7 @@ impl<'help> App<'help> { self.mut_arg("version", |a| a.short(c)) } - /// Deprecated, replaced with [`App::mut_arg`] + /// Deprecated, replaced with [`Command::mut_arg`] #[deprecated(since = "3.0.0", note = "Replaced with `App::mut_arg`")] #[doc(hidden)] #[must_use] @@ -3772,7 +3772,7 @@ impl<'help> App<'help> { self.mut_arg("help", |a| a.help(s.into())) } - /// Deprecated, replaced with [`App::mut_arg`] + /// Deprecated, replaced with [`Command::mut_arg`] #[deprecated(since = "3.0.0", note = "Replaced with `App::mut_arg`")] #[doc(hidden)] #[must_use] @@ -3780,7 +3780,7 @@ impl<'help> App<'help> { self.mut_arg("version", |a| a.help(s.into())) } - /// Deprecated, replaced with [`App::help_template`] + /// Deprecated, replaced with [`Command::help_template`] #[deprecated(since = "3.0.0", note = "Replaced with `App::help_template`")] #[doc(hidden)] #[must_use] @@ -3788,7 +3788,7 @@ impl<'help> App<'help> { self.help_template(s) } - /// Deprecated, replaced with [`App::setting(a| b)`] + /// Deprecated, replaced with [`Command::setting(a| b)`] #[deprecated(since = "3.0.0", note = "Replaced with `App::setting(a | b)`")] #[doc(hidden)] #[must_use] @@ -3799,7 +3799,7 @@ impl<'help> App<'help> { self } - /// Deprecated, replaced with [`App::unset_setting(a| b)`] + /// Deprecated, replaced with [`Command::unset_setting(a| b)`] #[deprecated(since = "3.0.0", note = "Replaced with `App::unset_setting(a | b)`")] #[doc(hidden)] #[must_use] @@ -3810,7 +3810,7 @@ impl<'help> App<'help> { self } - /// Deprecated, replaced with [`App::global_setting(a| b)`] + /// Deprecated, replaced with [`Command::global_setting(a| b)`] #[deprecated(since = "3.0.0", note = "Replaced with `App::global_setting(a | b)`")] #[doc(hidden)] #[must_use] @@ -3822,7 +3822,7 @@ impl<'help> App<'help> { self } - /// Deprecated, replaced with [`App::term_width`] + /// Deprecated, replaced with [`Command::term_width`] #[deprecated(since = "3.0.0", note = "Replaced with `App::term_width`")] #[doc(hidden)] #[must_use] @@ -3855,28 +3855,28 @@ impl<'help> App<'help> { self } - /// Deprecated, replaced with [`App::render_version`] + /// Deprecated, replaced with [`Command::render_version`] #[deprecated(since = "3.0.0", note = "Replaced with `App::render_version`")] #[doc(hidden)] pub fn write_version(&self, w: &mut W) -> ClapResult<()> { write!(w, "{}", self.render_version()).map_err(From::from) } - /// Deprecated, replaced with [`App::render_long_version`] + /// Deprecated, replaced with [`Command::render_long_version`] #[deprecated(since = "3.0.0", note = "Replaced with `App::render_long_version`")] #[doc(hidden)] pub fn write_long_version(&self, w: &mut W) -> ClapResult<()> { write!(w, "{}", self.render_long_version()).map_err(From::from) } - /// Deprecated, replaced with [`App::try_get_matches`] + /// Deprecated, replaced with [`Command::try_get_matches`] #[deprecated(since = "3.0.0", note = "Replaced with `App::try_get_matches`")] #[doc(hidden)] pub fn get_matches_safe(self) -> ClapResult { self.try_get_matches() } - /// Deprecated, replaced with [`App::try_get_matches_from`] + /// Deprecated, replaced with [`Command::try_get_matches_from`] #[deprecated(since = "3.0.0", note = "Replaced with `App::try_get_matches_from`")] #[doc(hidden)] pub fn get_matches_from_safe(self, itr: I) -> ClapResult @@ -3887,7 +3887,7 @@ impl<'help> App<'help> { self.try_get_matches_from(itr) } - /// Deprecated, replaced with [`App::try_get_matches_from_mut`] + /// Deprecated, replaced with [`Command::try_get_matches_from_mut`] #[deprecated( since = "3.0.0", note = "Replaced with `App::try_get_matches_from_mut`" @@ -4108,7 +4108,7 @@ impl<'help> App<'help> { .collect(); assert!(args_missing_help.is_empty(), - "AppSettings::HelpExpected is enabled for the App {}, but at least one of its arguments does not have either `help` or `long_help` set. List of such arguments: {}", + "AppSettings::HelpExpected is enabled for the Command {}, but at least one of its arguments does not have either `help` or `long_help` set. List of such arguments: {}", self.name, args_missing_help.join(", ") ); diff --git a/src/build/debug_asserts.rs b/src/build/debug_asserts.rs index 39ded8282b8..d29851d80ec 100644 --- a/src/build/debug_asserts.rs +++ b/src/build/debug_asserts.rs @@ -3,10 +3,10 @@ use std::cmp::Ordering; use crate::build::arg::ArgProvider; use crate::mkeymap::KeyType; use crate::util::Id; -use crate::{App, AppSettings, Arg, ValueHint}; +use crate::{AppSettings, Arg, Command, ValueHint}; -pub(crate) fn assert_app(app: &App) { - debug!("App::_debug_asserts"); +pub(crate) fn assert_app(app: &Command) { + debug!("Command::_debug_asserts"); let mut short_flags = vec![]; let mut long_flags = vec![]; @@ -16,18 +16,18 @@ pub(crate) fn assert_app(app: &App) { // PropagateVersion is meaningless if there is no version assert!( !app.is_propagate_version_set(), - "App {}: No version information via App::version or App::long_version to propagate", + "Command {}: No version information via Command::version or Command::long_version to propagate", app.get_name(), ); - // Used `App::mut_arg("version", ..) but did not provide any version information to display + // Used `Command::mut_arg("version", ..) but did not provide any version information to display let has_mutated_version = app .get_arguments() .any(|x| x.id == Id::version_hash() && x.provider == ArgProvider::GeneratedMutated); if has_mutated_version { assert!(app.is_set(AppSettings::NoAutoVersion), - "App {}: Used App::mut_arg(\"version\", ..) without providing App::version, App::long_version or using AppSettings::NoAutoVersion" + "Command {}: Used Command::mut_arg(\"version\", ..) without providing Command::version, Command::long_version or using AppSettings::NoAutoVersion" ,app.get_name() ); } @@ -35,19 +35,19 @@ pub(crate) fn assert_app(app: &App) { for sc in app.get_subcommands() { if let Some(s) = sc.get_short_flag().as_ref() { - short_flags.push(Flag::App(format!("-{}", s), sc.get_name())); + short_flags.push(Flag::Command(format!("-{}", s), sc.get_name())); } for short_alias in sc.get_all_short_flag_aliases() { - short_flags.push(Flag::App(format!("-{}", short_alias), sc.get_name())); + short_flags.push(Flag::Command(format!("-{}", short_alias), sc.get_name())); } if let Some(l) = sc.get_long_flag().as_ref() { - long_flags.push(Flag::App(format!("--{}", l), sc.get_name())); + long_flags.push(Flag::Command(format!("--{}", l), sc.get_name())); } for long_alias in sc.get_all_long_flag_aliases() { - long_flags.push(Flag::App(format!("--{}", long_alias), sc.get_name())); + long_flags.push(Flag::Command(format!("--{}", long_alias), sc.get_name())); } } @@ -73,7 +73,7 @@ pub(crate) fn assert_app(app: &App) { // Name conflicts assert!( app.two_args_of(|x| x.id == arg.id).is_none(), - "App {}: Argument names must be unique, but '{}' is in use by more than one argument or group", + "Command {}: Argument names must be unique, but '{}' is in use by more than one argument or group", app.get_name(), arg.name, ); @@ -82,7 +82,7 @@ pub(crate) fn assert_app(app: &App) { if let Some(l) = arg.long { if let Some((first, second)) = app.two_args_of(|x| x.long == Some(l)) { panic!( - "App {}: Long option names must be unique for each argument, \ + "Command {}: Long option names must be unique for each argument, \ but '--{}' is in use by both '{}' and '{}'", app.get_name(), l, @@ -96,7 +96,7 @@ pub(crate) fn assert_app(app: &App) { if let Some(s) = arg.short { if let Some((first, second)) = app.two_args_of(|x| x.short == Some(s)) { panic!( - "App {}: Short option names must be unique for each argument, \ + "Command {}: Short option names must be unique for each argument, \ but '-{}' is in use by both '{}' and '{}'", app.get_name(), s, @@ -112,7 +112,7 @@ pub(crate) fn assert_app(app: &App) { app.two_args_of(|x| x.is_positional() && x.index == Some(idx)) { panic!( - "App {}: Argument '{}' has the same index as '{}' \ + "Command {}: Argument '{}' has the same index as '{}' \ and they are both positional arguments\n\n\t \ Use Arg::multiple_values(true) to allow one \ positional argument to take multiple values", @@ -127,7 +127,7 @@ pub(crate) fn assert_app(app: &App) { for req in &arg.requires { assert!( app.id_exists(&req.1), - "App {}: Argument or group '{:?}' specified in 'requires*' for '{}' does not exist", + "Command {}: Argument or group '{:?}' specified in 'requires*' for '{}' does not exist", app.get_name(), req.1, arg.name, @@ -137,7 +137,7 @@ pub(crate) fn assert_app(app: &App) { for req in &arg.r_ifs { assert!( app.id_exists(&req.0), - "App {}: Argument or group '{:?}' specified in 'required_if_eq*' for '{}' does not exist", + "Command {}: Argument or group '{:?}' specified in 'required_if_eq*' for '{}' does not exist", app.get_name(), req.0, arg.name @@ -147,7 +147,7 @@ pub(crate) fn assert_app(app: &App) { for req in &arg.r_ifs_all { assert!( app.id_exists(&req.0), - "App {}: Argument or group '{:?}' specified in 'required_if_eq_all' for '{}' does not exist", + "Command {}: Argument or group '{:?}' specified in 'required_if_eq_all' for '{}' does not exist", app.get_name(), req.0, arg.name @@ -157,7 +157,7 @@ pub(crate) fn assert_app(app: &App) { for req in &arg.r_unless { assert!( app.id_exists(req), - "App {}: Argument or group '{:?}' specified in 'required_unless*' for '{}' does not exist", + "Command {}: Argument or group '{:?}' specified in 'required_unless*' for '{}' does not exist", app.get_name(), req, arg.name, @@ -168,7 +168,7 @@ pub(crate) fn assert_app(app: &App) { for req in &arg.blacklist { assert!( app.id_exists(req), - "App {}: Argument or group '{:?}' specified in 'conflicts_with*' for '{}' does not exist", + "Command {}: Argument or group '{:?}' specified in 'conflicts_with*' for '{}' does not exist", app.get_name(), req, arg.name, @@ -178,13 +178,13 @@ pub(crate) fn assert_app(app: &App) { if arg.is_last_set() { assert!( arg.long.is_none(), - "App {}: Flags or Options cannot have last(true) set. '{}' has both a long and last(true) set.", + "Command {}: Flags or Options cannot have last(true) set. '{}' has both a long and last(true) set.", app.get_name(), arg.name ); assert!( arg.short.is_none(), - "App {}: Flags or Options cannot have last(true) set. '{}' has both a short and last(true) set.", + "Command {}: Flags or Options cannot have last(true) set. '{}' has both a short and last(true) set.", app.get_name(), arg.name ); @@ -192,7 +192,7 @@ pub(crate) fn assert_app(app: &App) { assert!( !(arg.is_required_set() && arg.is_global_set()), - "App {}: Global arguments cannot be required.\n\n\t'{}' is marked as both global and required", + "Command {}: Global arguments cannot be required.\n\n\t'{}' is marked as both global and required", app.get_name(), arg.name ); @@ -200,7 +200,7 @@ pub(crate) fn assert_app(app: &App) { // validators assert!( arg.validator.is_none() || arg.validator_os.is_none(), - "App {}: Argument '{}' has both `validator` and `validator_os` set which is not allowed", + "Command {}: Argument '{}' has both `validator` and `validator_os` set which is not allowed", app.get_name(), arg.name ); @@ -208,14 +208,14 @@ pub(crate) fn assert_app(app: &App) { if arg.value_hint == ValueHint::CommandWithArguments { assert!( arg.is_positional(), - "App {}: Argument '{}' has hint CommandWithArguments and must be positional.", + "Command {}: Argument '{}' has hint CommandWithArguments and must be positional.", app.get_name(), arg.name ); assert!( app.is_trailing_var_arg_set(), - "App {}: Positional argument '{}' has hint CommandWithArguments, so App must have TrailingVarArg set.", + "Command {}: Positional argument '{}' has hint CommandWithArguments, so Command must have TrailingVarArg set.", app.get_name(), arg.name ); @@ -226,7 +226,7 @@ pub(crate) fn assert_app(app: &App) { // Name conflicts assert!( app.get_groups().filter(|x| x.id == group.id).count() < 2, - "App {}: Argument group name must be unique\n\n\t'{}' is already in use", + "Command {}: Argument group name must be unique\n\n\t'{}' is already in use", app.get_name(), group.name, ); @@ -234,7 +234,7 @@ pub(crate) fn assert_app(app: &App) { // Groups should not have naming conflicts with Args assert!( !app.get_arguments().any(|x| x.id == group.id), - "App {}: Argument group name '{}' must not conflict with argument name", + "Command {}: Argument group name '{}' must not conflict with argument name", app.get_name(), group.name, ); @@ -246,7 +246,7 @@ pub(crate) fn assert_app(app: &App) { app.get_arguments() .any(|x| x.id == *arg && x.default_vals.is_empty()) }), - "App {}: Argument group '{}' is required but all of it's arguments have a default value.", + "Command {}: Argument group '{}' is required but all of it's arguments have a default value.", app.get_name(), group.name ) @@ -256,7 +256,7 @@ pub(crate) fn assert_app(app: &App) { // Args listed inside groups should exist assert!( app.get_arguments().any(|x| x.id == *arg), - "App {}: Argument group '{}' contains non-existent argument '{:?}'", + "Command {}: Argument group '{}' contains non-existent argument '{:?}'", app.get_name(), group.name, arg @@ -277,13 +277,13 @@ pub(crate) fn assert_app(app: &App) { if let Some(help_template) = app.get_help_template() { assert!( !help_template.contains("{flags}"), - "App {}: {}", + "Command {}: {}", app.get_name(), "`{flags}` template variable was removed in clap3, they are now included in `{options}`", ); assert!( !help_template.contains("{unified}"), - "App {}: {}", + "Command {}: {}", app.get_name(), "`{unified}` template variable was removed in clap3, use `{options}` instead" ); @@ -295,7 +295,7 @@ pub(crate) fn assert_app(app: &App) { #[derive(Eq)] enum Flag<'a> { - App(String, &'a str), + Command(String, &'a str), Arg(String, &'a str), } @@ -310,10 +310,10 @@ impl PartialOrd for Flag<'_> { use Flag::*; match (self, other) { - (App(s1, _), App(s2, _)) + (Command(s1, _), Command(s2, _)) | (Arg(s1, _), Arg(s2, _)) - | (App(s1, _), Arg(s2, _)) - | (Arg(s1, _), App(s2, _)) => { + | (Command(s1, _), Arg(s2, _)) + | (Arg(s1, _), Command(s2, _)) => { if s1 == s2 { Some(Ordering::Equal) } else { @@ -335,7 +335,7 @@ fn detect_duplicate_flags(flags: &[Flag], short_or_long: &str) { for (one, two) in find_duplicates(flags) { match (one, two) { - (App(flag, one), App(_, another)) if one != another => panic!( + (Command(flag, one), Command(_, another)) if one != another => panic!( "the '{}' {} flag is specified for both '{}' and '{}' subcommands", flag, short_or_long, one, another ), @@ -345,7 +345,7 @@ fn detect_duplicate_flags(flags: &[Flag], short_or_long: &str) { short_or_long, flag, one, another ), - (Arg(flag, arg), App(_, sub)) | (App(flag, sub), Arg(_, arg)) => panic!( + (Arg(flag, arg), Command(_, sub)) | (Command(flag, sub), Arg(_, arg)) => panic!( "the '{}' {} flag for the '{}' argument conflicts with the short flag \ for '{}' subcommand", flag, short_or_long, arg, sub @@ -370,7 +370,7 @@ fn find_duplicates(slice: &[T]) -> impl Iterator }) } -fn assert_app_flags(app: &App) { +fn assert_app_flags(app: &Command) { macro_rules! checker { ($a:ident requires $($b:ident)|+) => { if app.$a() { @@ -410,8 +410,8 @@ fn assert_app_flags(app: &App) { } #[cfg(debug_assertions)] -fn _verify_positionals(app: &App) -> bool { - debug!("App::_verify_positionals"); +fn _verify_positionals(app: &Command) -> bool { + debug!("Command::_verify_positionals"); // Because you must wait until all arguments have been supplied, this is the first chance // to make assertions on positional argument indexes // diff --git a/src/build/mod.rs b/src/build/mod.rs index d7d4920ae6d..ae8c46b6363 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -24,11 +24,13 @@ pub use app_settings::{AppFlags, AppSettings}; pub use arg::Arg; pub use arg_group::ArgGroup; pub use arg_settings::{ArgFlags, ArgSettings}; -pub use command::App; pub use command::Command; pub use possible_value::PossibleValue; pub use value_hint::ValueHint; +#[allow(deprecated)] +pub use command::App; + #[cfg(feature = "regex")] pub use self::regex::RegexRef; diff --git a/src/build/tests.rs b/src/build/tests.rs index 946593d0975..1b7e1a4faaf 100644 --- a/src/build/tests.rs +++ b/src/build/tests.rs @@ -1,12 +1,12 @@ -use crate::App; use crate::Arg; +use crate::Command; #[test] fn propagate_version() { - let mut app = App::new("test") + let mut app = Command::new("test") .propagate_version(true) .version("1.1") - .subcommand(App::new("sub1")); + .subcommand(Command::new("sub1")); app._propagate(); assert_eq!( app.get_subcommands().next().unwrap().get_version(), @@ -16,9 +16,9 @@ fn propagate_version() { #[test] fn global_setting() { - let mut app = App::new("test") + let mut app = Command::new("test") .disable_version_flag(true) - .subcommand(App::new("subcmd")); + .subcommand(Command::new("subcmd")); app._propagate(); assert!(app .get_subcommands() @@ -27,18 +27,18 @@ fn global_setting() { .is_disable_version_flag_set()); } -// This test will *fail to compile* if App is not Send + Sync +// This test will *fail to compile* if Command is not Send + Sync #[test] fn app_send_sync() { fn foo(_: T) {} - foo(App::new("test")) + foo(Command::new("test")) } #[test] fn issue_2090() { - let mut app = App::new("app") + let mut app = Command::new("app") .disable_version_flag(true) - .subcommand(App::new("sub")); + .subcommand(Command::new("sub")); app._build(); assert!(app diff --git a/src/build/usage_parser.rs b/src/build/usage_parser.rs index 2aa624de2aa..ccfad66bfab 100644 --- a/src/build/usage_parser.rs +++ b/src/build/usage_parser.rs @@ -1246,8 +1246,8 @@ mod test { #[test] fn value_names_building_num_vals_from_usage() { - use crate::App; - let m = App::new("test") + use crate::Command; + let m = Command::new("test") .arg(Arg::from_usage("--pos ")) .try_get_matches_from(vec!["myprog", "--pos", "val1", "val2", "val3"]); @@ -1262,9 +1262,9 @@ mod test { #[test] fn issue_665() { - use crate::{error::ErrorKind, App}; + use crate::{error::ErrorKind, Command}; // Verify fix for "arg_from_usage(): required values not being enforced when followed by another option" - let res = App::new("tester") + let res = Command::new("tester") .arg(Arg::from_usage("-v, --reroll-count=[N] 'Mark the patch series as PATCH vN'")) .arg( Arg::from_usage("--subject-prefix [Subject-Prefix] 'Use [Subject-Prefix] instead of the standard [PATCH] prefix'") diff --git a/src/build/value_hint.rs b/src/build/value_hint.rs index 3f8d591ce68..647adcc52b7 100644 --- a/src/build/value_hint.rs +++ b/src/build/value_hint.rs @@ -48,11 +48,11 @@ pub enum ValueHint { /// common when writing shell wrappers that execute anther command, for example `sudo` or `env`. /// /// This hint is special, the argument must be a positional argument and have - /// [`.multiple_values(true)`] and App must use [`App::trailing_var_arg(true)`]. The result is that the + /// [`.multiple_values(true)`] and Command must use [`Command::trailing_var_arg(true)`]. The result is that the /// command line `my_app ls -la /` will be parsed as `["ls", "-la", "/"]` and clap won't try to /// parse the `-la` argument itself. /// - /// [`App::trailing_var_arg(true)`]: crate::App::trailing_var_arg + /// [`Command::trailing_var_arg(true)`]: crate::Command::trailing_var_arg /// [`.multiple_values(true)`]: crate::Arg::multiple_values() CommandWithArguments, /// Name of a local operating system user. diff --git a/src/derive.rs b/src/derive.rs index ffe70896a54..67807ba9fa6 100644 --- a/src/derive.rs +++ b/src/derive.rs @@ -1,14 +1,14 @@ //! This module contains traits that are usable with the `#[derive(...)].` //! macros in [`clap_derive`]. -use crate::{App, ArgMatches, Error, PossibleValue}; +use crate::{ArgMatches, Command, Error, PossibleValue}; use std::ffi::OsString; /// Parse command-line arguments into `Self`. /// /// The primary one-stop-shop trait used to create an instance of a `clap` -/// [`App`], conduct the parsing, and turn the resulting [`ArgMatches`] back +/// [`Command`], conduct the parsing, and turn the resulting [`ArgMatches`] back /// into concrete instance of the user struct. /// /// This trait is primarily a convenience on top of [`FromArgMatches`] + @@ -46,11 +46,11 @@ use std::ffi::OsString; /// } /// ``` /// -/// The equivalent [`App`] struct + `From` implementation: +/// The equivalent [`Command`] struct + `From` implementation: /// /// ```rust -/// # use clap::{App, Arg, ArgMatches}; -/// App::new("demo") +/// # use clap::{Command, Arg, ArgMatches}; +/// Command::new("demo") /// .about("My super CLI") /// .arg(Arg::new("verbose") /// .long("verbose") @@ -154,14 +154,14 @@ pub trait Parser: FromArgMatches + IntoApp + Sized { .map_err(format_error::) } - /// Deprecated, `StructOpt::clap` replaced with [`IntoApp::into_app`] (derive as part of + /// Deprecated, `StructOpt::clap` replaced with [`IntoCommand::into_app`] (derive as part of /// [`Parser`]) #[deprecated( since = "3.0.0", - note = "`StructOpt::clap` is replaced with `IntoApp::into_app` (derived as part of `Parser`)" + note = "`StructOpt::clap` is replaced with `IntoCommand::into_app` (derived as part of `Parser`)" )] #[doc(hidden)] - fn clap<'help>() -> App<'help> { + fn clap<'help>() -> Command<'help> { ::into_app() } @@ -226,18 +226,18 @@ pub trait Parser: FromArgMatches + IntoApp + Sized { } } -/// Create an [`App`] relevant for a user-defined container. +/// Create an [`Command`] relevant for a user-defined container. /// /// Derived as part of [`Parser`]. pub trait IntoApp: Sized { - /// Build an [`App`] that can instantiate `Self`. + /// Build an [`Command`] that can instantiate `Self`. /// /// See [`FromArgMatches::from_arg_matches`] for instantiating `Self`. - fn into_app<'help>() -> App<'help>; - /// Build an [`App`] that can update `self`. + fn into_app<'help>() -> Command<'help>; + /// Build an [`Command`] that can update `self`. /// /// See [`FromArgMatches::update_from_arg_matches`] for updating `self`. - fn into_app_for_update<'help>() -> App<'help>; + fn into_app_for_update<'help>() -> Command<'help>; } /// Converts an instance of [`ArgMatches`] to a user-defined container. @@ -313,16 +313,16 @@ pub trait FromArgMatches: Sized { /// } /// ``` pub trait Args: FromArgMatches + Sized { - /// Append to [`App`] so it can instantiate `Self`. + /// Append to [`Command`] so it can instantiate `Self`. /// /// See also [`IntoApp`]. - fn augment_args(app: App<'_>) -> App<'_>; - /// Append to [`App`] so it can update `self`. + fn augment_args(app: Command<'_>) -> Command<'_>; + /// Append to [`Command`] so it can update `self`. /// /// This is used to implement `#[clap(flatten)]` /// /// See also [`IntoApp`]. - fn augment_args_for_update(app: App<'_>) -> App<'_>; + fn augment_args_for_update(app: Command<'_>) -> Command<'_>; } /// Parse a sub-command into a user-defined enum. @@ -357,16 +357,16 @@ pub trait Args: FromArgMatches + Sized { /// } /// ``` pub trait Subcommand: FromArgMatches + Sized { - /// Append to [`App`] so it can instantiate `Self`. + /// Append to [`Command`] so it can instantiate `Self`. /// /// See also [`IntoApp`]. - fn augment_subcommands(app: App<'_>) -> App<'_>; - /// Append to [`App`] so it can update `self`. + fn augment_subcommands(app: Command<'_>) -> Command<'_>; + /// Append to [`Command`] so it can update `self`. /// /// This is used to implement `#[clap(flatten)]` /// /// See also [`IntoApp`]. - fn augment_subcommands_for_update(app: App<'_>) -> App<'_>; + fn augment_subcommands_for_update(app: Command<'_>) -> Command<'_>; /// Test whether `Self` can parse a specific subcommand fn has_subcommand(name: &str) -> bool; } @@ -452,10 +452,10 @@ impl Parser for Box { } impl IntoApp for Box { - fn into_app<'help>() -> App<'help> { + fn into_app<'help>() -> Command<'help> { ::into_app() } - fn into_app_for_update<'help>() -> App<'help> { + fn into_app_for_update<'help>() -> Command<'help> { ::into_app_for_update() } } @@ -470,19 +470,19 @@ impl FromArgMatches for Box { } impl Args for Box { - fn augment_args(app: App<'_>) -> App<'_> { + fn augment_args(app: Command<'_>) -> Command<'_> { ::augment_args(app) } - fn augment_args_for_update(app: App<'_>) -> App<'_> { + fn augment_args_for_update(app: Command<'_>) -> Command<'_> { ::augment_args_for_update(app) } } impl Subcommand for Box { - fn augment_subcommands(app: App<'_>) -> App<'_> { + fn augment_subcommands(app: Command<'_>) -> Command<'_> { ::augment_subcommands(app) } - fn augment_subcommands_for_update(app: App<'_>) -> App<'_> { + fn augment_subcommands_for_update(app: Command<'_>) -> Command<'_> { ::augment_subcommands_for_update(app) } fn has_subcommand(name: &str) -> bool { diff --git a/src/error/kind.rs b/src/error/kind.rs index b93601d9585..1d27f433d62 100644 --- a/src/error/kind.rs +++ b/src/error/kind.rs @@ -8,8 +8,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("speed") /// .possible_value("fast") /// .possible_value("slow")) @@ -24,8 +24,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(arg!(--flag "some flag")) /// .try_get_matches_from(vec!["prog", "--other"]); /// assert!(result.is_err()); @@ -42,9 +42,9 @@ pub enum ErrorKind { /// #[cfg_attr(not(feature = "suggestions"), doc = " ```no_run")] #[cfg_attr(feature = "suggestions", doc = " ```")] - /// # use clap::{App, Arg, ErrorKind, }; - /// let result = App::new("prog") - /// .subcommand(App::new("config") + /// # use clap::{Command, Arg, ErrorKind, }; + /// let result = Command::new("prog") + /// .subcommand(Command::new("config") /// .about("Used for configuration") /// .arg(Arg::new("config_file") /// .help("The configuration file to use") @@ -69,9 +69,9 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind, }; - /// let result = App::new("prog") - /// .subcommand(App::new("config") + /// # use clap::{Command, Arg, ErrorKind, }; + /// let result = Command::new("prog") + /// .subcommand(Command::new("config") /// .about("Used for configuration") /// .arg(Arg::new("config_file") /// .help("The configuration file to use") @@ -92,8 +92,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("color") /// .takes_value(true) /// .forbid_empty_values(true) @@ -108,8 +108,8 @@ pub enum ErrorKind { /// sign to provide values. /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let res = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let res = Command::new("prog") /// .arg(Arg::new("color") /// .takes_value(true) /// .require_equals(true) @@ -126,7 +126,7 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; + /// # use clap::{Command, Arg, ErrorKind}; /// fn is_numeric(val: &str) -> Result<(), String> { /// match val.parse::() { /// Ok(..) => Ok(()), @@ -134,7 +134,7 @@ pub enum ErrorKind { /// } /// } /// - /// let result = App::new("prog") + /// let result = Command::new("prog") /// .arg(Arg::new("num") /// .validator(is_numeric)) /// .try_get_matches_from(vec!["prog", "NotANumber"]); @@ -149,8 +149,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("arg") /// .max_values(2)) /// .try_get_matches_from(vec!["prog", "too", "many", "values"]); @@ -166,8 +166,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("some_opt") /// .long("opt") /// .min_values(3)) @@ -184,8 +184,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("verbosity") /// .short('v') /// .max_occurrences(2)) @@ -203,8 +203,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("some_opt") /// .long("opt") /// .takes_value(true) @@ -224,8 +224,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("debug") /// .long("debug") /// .conflicts_with("color")) @@ -242,8 +242,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("debug") /// .required(true)) /// .try_get_matches_from(vec!["prog"]); @@ -252,16 +252,16 @@ pub enum ErrorKind { /// ``` MissingRequiredArgument, - /// Occurs when a subcommand is required (as defined by [`App::subcommand_required`]), + /// Occurs when a subcommand is required (as defined by [`Command::subcommand_required`]), /// but the user does not provide one. /// /// # Examples /// /// ```rust - /// # use clap::{App, ErrorKind}; - /// let err = App::new("prog") + /// # use clap::{Command, ErrorKind}; + /// let err = Command::new("prog") /// .subcommand_required(true) - /// .subcommand(App::new("test")) + /// .subcommand(Command::new("test")) /// .try_get_matches_from(vec![ /// "myprog", /// ]); @@ -270,7 +270,7 @@ pub enum ErrorKind { /// # ; /// ``` /// - /// [`App::subcommand_required`]: crate::App::subcommand_required + /// [`Command::subcommand_required`]: crate::Command::subcommand_required MissingSubcommand, /// Occurs when the user provides multiple values to an argument which doesn't allow that. @@ -278,8 +278,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .arg(Arg::new("debug") /// .long("debug") /// .multiple_occurrences(false)) @@ -293,7 +293,7 @@ pub enum ErrorKind { /// /// To allow arbitrary data /// - Set [`Arg::allow_invalid_utf8`] for argument values - /// - Set [`App::allow_invalid_utf8_for_external_subcommands`] for external-subcommand + /// - Set [`Command::allow_invalid_utf8_for_external_subcommands`] for external-subcommand /// values /// /// # Platform Specific @@ -304,10 +304,10 @@ pub enum ErrorKind { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::{App, Arg, ErrorKind}; + /// # use clap::{Command, Arg, ErrorKind}; /// # use std::os::unix::ffi::OsStringExt; /// # use std::ffi::OsString; - /// let result = App::new("prog") + /// let result = Command::new("prog") /// .arg(Arg::new("utf8") /// .short('u') /// .takes_value(true)) @@ -319,7 +319,7 @@ pub enum ErrorKind { /// ``` /// /// [`Arg::allow_invalid_utf8`]: crate::Arg::allow_invalid_utf8 - /// [`App::allow_invalid_utf8_for_external_subcommands`]: crate::App::allow_invalid_utf8_for_external_subcommands + /// [`Command::allow_invalid_utf8_for_external_subcommands`]: crate::Command::allow_invalid_utf8_for_external_subcommands InvalidUtf8, /// Not a true "error" as it means `--help` or similar was used. @@ -331,8 +331,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .try_get_matches_from(vec!["prog", "--help"]); /// assert!(result.is_err()); /// assert_eq!(result.unwrap_err().kind(), ErrorKind::DisplayHelp); @@ -340,16 +340,16 @@ pub enum ErrorKind { DisplayHelp, /// Occurs when either an argument or a [`Subcommand`] is required, as defined by - /// [`App::arg_required_else_help`] , but the user did not provide + /// [`Command::arg_required_else_help`] , but the user did not provide /// one. /// /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind, }; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind, }; + /// let result = Command::new("prog") /// .arg_required_else_help(true) - /// .subcommand(App::new("config") + /// .subcommand(Command::new("config") /// .about("Used for configuration") /// .arg(Arg::new("config_file") /// .help("The configuration file to use"))) @@ -359,7 +359,7 @@ pub enum ErrorKind { /// ``` /// /// [`Subcommand`]: crate::Subcommand - /// [`App::arg_required_else_help`]: crate::App::arg_required_else_help + /// [`Command::arg_required_else_help`]: crate::Command::arg_required_else_help DisplayHelpOnMissingArgumentOrSubcommand, /// Not a true "error" as it means `--version` or similar was used. @@ -368,8 +368,8 @@ pub enum ErrorKind { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, ErrorKind}; - /// let result = App::new("prog") + /// # use clap::{Command, Arg, ErrorKind}; + /// let result = Command::new("prog") /// .version("3.0") /// .try_get_matches_from(vec!["prog", "--version"]); /// assert!(result.is_err()); diff --git a/src/error/mod.rs b/src/error/mod.rs index 75aaa5131b8..d000738848f 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -17,7 +17,7 @@ use crate::{ output::fmt::Colorizer, parse::features::suggestions, util::{color::ColorChoice, safe_exit, SUCCESS_CODE, USAGE_CODE}, - App, AppSettings, + AppSettings, Command, }; mod context; @@ -34,9 +34,9 @@ pub type Result = StdResult; /// Command Line Argument Parser Error /// -/// See [`App::error`] to create an error. +/// See [`Command::error`] to create an error. /// -/// [`App::error`]: crate::App::error +/// [`Command::error`]: crate::Command::error #[derive(Debug)] pub struct Error { inner: Box, @@ -64,18 +64,18 @@ impl Error { /// Create an unformatted error /// /// This is for you need to pass the error up to - /// a place that has access to the `App` at which point you can call [`Error::format`]. + /// a place that has access to the `Command` at which point you can call [`Error::format`]. /// - /// Prefer [`App::error`] for generating errors. + /// Prefer [`Command::error`] for generating errors. /// - /// [`App::error`]: crate::App::error + /// [`Command::error`]: crate::Command::error pub fn raw(kind: ErrorKind, message: impl std::fmt::Display) -> Self { Self::new(kind).set_message(message.to_string()) } - /// Format the existing message with the App's context + /// Format the existing message with the Command's context #[must_use] - pub fn format(mut self, app: &mut App) -> Self { + pub fn format(mut self, app: &mut Command) -> Self { app._build(); let usage = app.render_usage(); if let Some(message) = self.inner.message.as_mut() { @@ -131,9 +131,9 @@ impl Error { /// /// # Example /// ```no_run - /// use clap::App; + /// use clap::Command; /// - /// match App::new("App").try_get_matches() { + /// match Command::new("Command").try_get_matches() { /// Ok(matches) => { /// // do_something /// }, @@ -147,10 +147,10 @@ impl Error { self.formatted().print() } - /// Deprecated, replaced with [`App::error`] + /// Deprecated, replaced with [`Command::error`] /// - /// [`App::error`]: crate::App::error - #[deprecated(since = "3.0.0", note = "Replaced with `App::error`")] + /// [`Command::error`]: crate::Command::error + #[deprecated(since = "3.0.0", note = "Replaced with `Command::error`")] #[doc(hidden)] pub fn with_description(description: String, kind: ErrorKind) -> Self { Error::raw(kind, description) @@ -174,14 +174,14 @@ impl Error { } #[inline(never)] - fn for_app(kind: ErrorKind, app: &App, colorizer: Colorizer, info: Vec) -> Self { + fn for_app(kind: ErrorKind, app: &Command, colorizer: Colorizer, info: Vec) -> Self { Self::new(kind) .set_message(colorizer) .with_app(app) .set_info(info) } - pub(crate) fn with_app(self, app: &App) -> Self { + pub(crate) fn with_app(self, app: &Command) -> Self { self.set_wait_on_exit(app.is_set(AppSettings::WaitOnError)) .set_color(app.get_color()) .set_help_flag(get_help_flag(app)) @@ -246,11 +246,11 @@ impl Error { .find_map(|(k, v)| (*k == kind).then(|| v)) } - pub(crate) fn display_help(app: &App, colorizer: Colorizer) -> Self { + pub(crate) fn display_help(app: &Command, colorizer: Colorizer) -> Self { Self::for_app(ErrorKind::DisplayHelp, app, colorizer, vec![]) } - pub(crate) fn display_help_error(app: &App, colorizer: Colorizer) -> Self { + pub(crate) fn display_help_error(app: &Command, colorizer: Colorizer) -> Self { Self::for_app( ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand, app, @@ -259,12 +259,12 @@ impl Error { ) } - pub(crate) fn display_version(app: &App, colorizer: Colorizer) -> Self { + pub(crate) fn display_version(app: &Command, colorizer: Colorizer) -> Self { Self::for_app(ErrorKind::DisplayVersion, app, colorizer, vec![]) } pub(crate) fn argument_conflict( - app: &App, + app: &Command, arg: &Arg, mut others: Vec, usage: String, @@ -288,7 +288,7 @@ impl Error { ]) } - pub(crate) fn empty_value(app: &App, good_vals: &[&str], arg: &Arg, usage: String) -> Self { + pub(crate) fn empty_value(app: &Command, good_vals: &[&str], arg: &Arg, usage: String) -> Self { let info = vec![arg.to_string()]; let mut err = Self::new(ErrorKind::EmptyValue) .with_app(app) @@ -309,7 +309,7 @@ impl Error { err } - pub(crate) fn no_equals(app: &App, arg: String, usage: String) -> Self { + pub(crate) fn no_equals(app: &Command, arg: String, usage: String) -> Self { let info = vec![arg.to_string()]; Self::new(ErrorKind::NoEquals) .with_app(app) @@ -321,7 +321,7 @@ impl Error { } pub(crate) fn invalid_value( - app: &App, + app: &Command, bad_val: String, good_vals: &[&str], arg: &Arg, @@ -356,7 +356,7 @@ impl Error { } pub(crate) fn invalid_subcommand( - app: &App, + app: &Command, subcmd: String, did_you_mean: String, name: String, @@ -381,7 +381,7 @@ impl Error { ]) } - pub(crate) fn unrecognized_subcommand(app: &App, subcmd: String, name: String) -> Self { + pub(crate) fn unrecognized_subcommand(app: &Command, subcmd: String, name: String) -> Self { let info = vec![subcmd.clone()]; let usage = format!("USAGE:\n {} ", name); Self::new(ErrorKind::UnrecognizedSubcommand) @@ -394,7 +394,7 @@ impl Error { } pub(crate) fn missing_required_argument( - app: &App, + app: &Command, required: Vec, usage: String, ) -> Self { @@ -408,7 +408,7 @@ impl Error { ]) } - pub(crate) fn missing_subcommand(app: &App, name: String, usage: String) -> Self { + pub(crate) fn missing_subcommand(app: &Command, name: String, usage: String) -> Self { let info = vec![]; Self::new(ErrorKind::MissingSubcommand) .with_app(app) @@ -419,7 +419,7 @@ impl Error { ]) } - pub(crate) fn invalid_utf8(app: &App, usage: String) -> Self { + pub(crate) fn invalid_utf8(app: &Command, usage: String) -> Self { let info = vec![]; Self::new(ErrorKind::InvalidUtf8) .with_app(app) @@ -428,7 +428,7 @@ impl Error { } pub(crate) fn too_many_occurrences( - app: &App, + app: &Command, arg: &Arg, max_occurs: usize, curr_occurs: usize, @@ -459,7 +459,7 @@ impl Error { ]) } - pub(crate) fn too_many_values(app: &App, val: String, arg: String, usage: String) -> Self { + pub(crate) fn too_many_values(app: &Command, val: String, arg: String, usage: String) -> Self { let info = vec![arg.to_string(), val.clone()]; Self::new(ErrorKind::TooManyValues) .with_app(app) @@ -472,7 +472,7 @@ impl Error { } pub(crate) fn too_few_values( - app: &App, + app: &Command, arg: &Arg, min_vals: usize, curr_vals: usize, @@ -515,7 +515,7 @@ impl Error { } pub(crate) fn wrong_number_of_values( - app: &App, + app: &Command, arg: &Arg, num_vals: usize, curr_vals: usize, @@ -542,7 +542,7 @@ impl Error { ]) } - pub(crate) fn unexpected_multiple_usage(app: &App, arg: &Arg, usage: String) -> Self { + pub(crate) fn unexpected_multiple_usage(app: &Command, arg: &Arg, usage: String) -> Self { let info = vec![arg.to_string()]; Self::new(ErrorKind::UnexpectedMultipleUsage) .with_app(app) @@ -557,7 +557,7 @@ impl Error { } pub(crate) fn unknown_argument( - app: &App, + app: &Command, arg: String, did_you_mean: Option<(String, Option)>, usage: String, @@ -585,7 +585,7 @@ impl Error { err } - pub(crate) fn unnecessary_double_dash(app: &App, arg: String, usage: String) -> Self { + pub(crate) fn unnecessary_double_dash(app: &Command, arg: String, usage: String) -> Self { let info = vec![arg.to_string()]; Self::new(ErrorKind::UnknownArgument) .with_app(app) @@ -1046,7 +1046,7 @@ fn put_usage(c: &mut Colorizer, usage: impl Into) { c.none(usage); } -fn get_help_flag(app: &App) -> Option<&'static str> { +fn get_help_flag(app: &Command) -> Option<&'static str> { if !app.is_disable_help_flag_set() { Some("--help") } else if app.has_subcommands() && !app.is_disable_help_subcommand_set() { @@ -1087,7 +1087,7 @@ pub(crate) enum Message { } impl Message { - fn format(&mut self, app: &App, usage: String) { + fn format(&mut self, app: &Command, usage: String) { match self { Message::Raw(s) => { let mut c = Colorizer::new(true, app.get_color()); diff --git a/src/lib.rs b/src/lib.rs index 54b29c67aa6..6e4c3b8b1a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ compile_error!("`std` feature is currently required to build `clap`"); pub use crate::build::Command; pub use crate::build::{ - App, AppFlags, AppSettings, Arg, ArgFlags, ArgGroup, ArgSettings, PossibleValue, ValueHint, + AppFlags, AppSettings, Arg, ArgFlags, ArgGroup, ArgSettings, PossibleValue, ValueHint, }; pub use crate::error::Error; pub use crate::parse::{ArgMatches, Indices, OsValues, ValueSource, Values}; @@ -39,6 +39,9 @@ pub use crate::derive::{ArgEnum, Args, FromArgMatches, IntoApp, Parser, Subcomma pub use crate::error::{ErrorKind, Result}; +#[allow(deprecated)] +pub use crate::build::App; + #[cfg(feature = "yaml")] #[doc(hidden)] #[deprecated( @@ -82,10 +85,10 @@ const INTERNAL_ERROR_MSG: &str = "Fatal internal error. Please consider filing a report at https://github.com/clap-rs/clap/issues"; const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point"; -/// Deprecated, replaced with [`App::new`], unless you were looking for [Subcommand] +/// Deprecated, replaced with [`Command::new`], unless you were looking for [Subcommand] #[deprecated( since = "3.0.0", - note = "Replaced with `App::new` unless you intended the `Subcommand` trait" + note = "Replaced with `Command::new` unless you intended the `Subcommand` trait" )] #[doc(hidden)] #[derive(Debug, Copy, Clone)] @@ -93,12 +96,12 @@ pub struct SubCommand {} #[allow(deprecated)] impl SubCommand { - /// Deprecated, replaced with [`App::new`]. + /// Deprecated, replaced with [`Command::new`]. /// Did you mean Subcommand (lower-case c)? - #[deprecated(since = "3.0.0", note = "Replaced with `App::new`")] + #[deprecated(since = "3.0.0", note = "Replaced with `Command::new`")] #[doc(hidden)] pub fn with_name<'help>(name: &str) -> App<'help> { - App::new(name) + Command::new(name) } /// Deprecated in [Issue #3087](https://github.com/clap-rs/clap/issues/3087), maybe [`clap::Parser`][crate::Parser] would fit your use case? @@ -110,6 +113,6 @@ impl SubCommand { #[doc(hidden)] pub fn from_yaml(yaml: &yaml_rust::Yaml) -> App { #![allow(deprecated)] - App::from_yaml(yaml) + Command::from_yaml(yaml) } } diff --git a/src/macros.rs b/src/macros.rs index e6a3bc11f17..a04cf0323d2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -186,9 +186,9 @@ macro_rules! arg_enum { /// ```no_run /// # #[macro_use] /// # extern crate clap; -/// # use clap::App; +/// # use clap::Command; /// # fn main() { -/// let m = App::new("app") +/// let m = Command::new("app") /// .version(crate_version!()) /// .get_matches(); /// # } @@ -215,9 +215,9 @@ macro_rules! crate_version { /// ```no_run /// # #[macro_use] /// # extern crate clap; -/// # use clap::App; +/// # use clap::Command; /// # fn main() { -/// let m = App::new("app") +/// let m = Command::new("app") /// .author(crate_authors!("\n")) /// .get_matches(); /// # } @@ -245,9 +245,9 @@ macro_rules! crate_authors { /// ```no_run /// # #[macro_use] /// # extern crate clap; -/// # use clap::App; +/// # use clap::Command; /// # fn main() { -/// let m = App::new("app") +/// let m = Command::new("app") /// .about(crate_description!()) /// .get_matches(); /// # } @@ -267,9 +267,9 @@ macro_rules! crate_description { /// ```no_run /// # #[macro_use] /// # extern crate clap; -/// # use clap::App; +/// # use clap::Command; /// # fn main() { -/// let m = App::new(crate_name!()) +/// let m = Command::new(crate_name!()) /// .get_matches(); /// # } /// ``` @@ -281,7 +281,7 @@ macro_rules! crate_name { }; } -/// Allows you to build the `App` instance from your Cargo.toml at compile time. +/// Allows you to build the `Command` instance from your Cargo.toml at compile time. /// /// Equivalent to using the `crate_*!` macros with their respective fields. /// @@ -308,7 +308,7 @@ macro_rules! crate_name { #[macro_export] macro_rules! app_from_crate { () => {{ - let mut app = $crate::App::new($crate::crate_name!()).version($crate::crate_version!()); + let mut app = $crate::Command::new($crate::crate_name!()).version($crate::crate_version!()); let author = $crate::crate_authors!(", "); if !author.is_empty() { @@ -323,7 +323,7 @@ macro_rules! app_from_crate { app }}; ($sep:expr) => {{ - let mut app = $crate::App::new($crate::crate_name!()).version($crate::crate_version!()); + let mut app = $crate::Command::new($crate::crate_name!()).version($crate::crate_version!()); let author = $crate::crate_authors!($sep); if !author.is_empty() { @@ -607,8 +607,8 @@ macro_rules! arg_impl { /// # Examples /// /// ```rust -/// # use clap::{App, Arg, arg}; -/// App::new("prog") +/// # use clap::{Command, Arg, arg}; +/// Command::new("prog") /// .args(&[ /// arg!(--config "a required file for the configuration and no short"), /// arg!(-d --debug ... "turns on debugging information and allows multiples"), @@ -688,7 +688,7 @@ macro_rules! clap_app { (@app ($builder:expr) (@subcommand $name:ident => $($tail:tt)*) $($tt:tt)*) => { $crate::clap_app!{ @app ($builder.subcommand( - $crate::clap_app!{ @app ($crate::App::new(stringify!($name))) $($tail)* } + $crate::clap_app!{ @app ($crate::Command::new(stringify!($name))) $($tail)* } )) $($tt)* } @@ -780,15 +780,15 @@ macro_rules! clap_app { // Build a subcommand outside of an app. (@subcommand $name:ident => $($tail:tt)*) => { - $crate::clap_app!{ @app ($crate::App::new(stringify!($name))) $($tail)* } + $crate::clap_app!{ @app ($crate::Command::new(stringify!($name))) $($tail)* } }; // Start the magic (($name:expr) => $($tail:tt)*) => {{ - $crate::clap_app!{ @app ($crate::App::new($name)) $($tail)*} + $crate::clap_app!{ @app ($crate::Command::new($name)) $($tail)*} }}; ($name:ident => $($tail:tt)*) => {{ - $crate::clap_app!{ @app ($crate::App::new(stringify!($name))) $($tail)*} + $crate::clap_app!{ @app ($crate::Command::new(stringify!($name))) $($tail)*} }}; } diff --git a/src/output/help.rs b/src/output/help.rs index e14a0828a24..e0aaacb3a7f 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -9,7 +9,7 @@ use std::{ // Internal use crate::{ - build::{display_arg_val, App, Arg}, + build::{display_arg_val, Arg, Command}, output::{fmt::Colorizer, Usage}, }; @@ -22,7 +22,7 @@ use textwrap::core::display_width; /// Wraps a writer stream providing different methods to generate help for `clap` objects. pub(crate) struct Help<'help, 'app, 'writer> { writer: HelpWriter<'writer>, - app: &'app App<'help>, + app: &'app Command<'help>, usage: &'app Usage<'help, 'app>, next_line_help: bool, term_w: usize, @@ -48,7 +48,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { /// Create a new `Help` instance. pub(crate) fn new( writer: HelpWriter<'writer>, - app: &'app App<'help>, + app: &'app Command<'help>, usage: &'app Usage<'help, 'app>, use_long: bool, ) -> Self { @@ -656,7 +656,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { fn write_subcommand( &mut self, sc_str: &str, - app: &App<'help>, + app: &Command<'help>, next_line_help: bool, longest: usize, ) -> io::Result<()> { @@ -673,7 +673,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { self.help(false, about, spec_vals, next_line_help, longest) } - fn sc_spec_vals(&self, a: &App) -> String { + fn sc_spec_vals(&self, a: &Command) -> String { debug!("Help::sc_spec_vals: a={}", a.get_name()); let mut spec_vals = vec![]; if 0 < a.get_all_aliases().count() || 0 < a.get_all_short_flag_aliases().count() { @@ -704,7 +704,12 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { spec_vals.join(" ") } - fn subcommand_next_line_help(&self, app: &App<'help>, spec_vals: &str, longest: usize) -> bool { + fn subcommand_next_line_help( + &self, + app: &Command<'help>, + spec_vals: &str, + longest: usize, + ) -> bool { if self.next_line_help | self.use_long { // setting_next_line true @@ -818,7 +823,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { /// Will use next line help on writing subcommands. fn will_subcommands_wrap<'a>( &self, - subcommands: impl IntoIterator>, + subcommands: impl IntoIterator>, longest: usize, ) -> bool where @@ -834,7 +839,7 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { } /// Writes help for subcommands of a Parser Object to the wrapped stream. - fn write_subcommands(&mut self, app: &App<'help>) -> io::Result<()> { + fn write_subcommands(&mut self, app: &Command<'help>) -> io::Result<()> { debug!("Help::write_subcommands"); // The shortest an arg can legally be is 2 (i.e. '-x') let mut longest = 2; @@ -895,9 +900,9 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> { /// Write help to stream for the parser in the format defined by the template. /// - /// For details about the template language see [`App::help_template`]. + /// For details about the template language see [`Command::help_template`]. /// - /// [`App::help_template`]: App::help_template() + /// [`Command::help_template`]: Command::help_template() fn write_templated_help(&mut self, template: &str) -> io::Result<()> { debug!("Help::write_templated_help"); @@ -1022,7 +1027,7 @@ fn should_show_arg(use_long: bool, arg: &Arg) -> bool { || arg.is_next_line_help_set() } -fn should_show_subcommand(subcommand: &App) -> bool { +fn should_show_subcommand(subcommand: &Command) -> bool { !subcommand.is_hide_set() } diff --git a/src/output/usage.rs b/src/output/usage.rs index ecbf85b6310..18e3494d683 100644 --- a/src/output/usage.rs +++ b/src/output/usage.rs @@ -2,19 +2,19 @@ use indexmap::IndexSet; // Internal use crate::build::AppSettings as AS; -use crate::build::{App, Arg, ArgPredicate}; +use crate::build::{Arg, ArgPredicate, Command}; use crate::parse::ArgMatcher; use crate::util::ChildGraph; use crate::util::Id; use crate::INTERNAL_ERROR_MSG; pub(crate) struct Usage<'help, 'app> { - app: &'app App<'help>, + app: &'app Command<'help>, required: Option<&'app ChildGraph>, } impl<'help, 'app> Usage<'help, 'app> { - pub(crate) fn new(app: &'app App<'help>) -> Self { + pub(crate) fn new(app: &'app Command<'help>) -> Self { Usage { app, required: None, diff --git a/src/parse/arg_matcher.rs b/src/parse/arg_matcher.rs index 8a6833bd7b3..580f996196f 100644 --- a/src/parse/arg_matcher.rs +++ b/src/parse/arg_matcher.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, ffi::OsString, mem, ops::Deref}; // Internal use crate::{ - build::{App, Arg, ArgPredicate}, + build::{Arg, ArgPredicate, Command}, parse::{ArgMatches, MatchedArg, SubCommand, ValueSource}, util::Id, }; @@ -15,7 +15,7 @@ use indexmap::map::Entry; pub(crate) struct ArgMatcher(ArgMatches); impl ArgMatcher { - pub(crate) fn new(_app: &App) -> Self { + pub(crate) fn new(_app: &Command) -> Self { ArgMatcher(ArgMatches { #[cfg(debug_assertions)] valid_args: { diff --git a/src/parse/features/suggestions.rs b/src/parse/features/suggestions.rs index ddb9c17dca6..76d16ac829a 100644 --- a/src/parse/features/suggestions.rs +++ b/src/parse/features/suggestions.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; // Internal -use crate::build::App; +use crate::build::Command; /// Produces multiple strings from a given list of possible values which are similar /// to the passed in value `v` within a certain confidence by least confidence. @@ -37,7 +37,7 @@ pub(crate) fn did_you_mean_flag<'a, 'help, I, T>( arg: &str, remaining_args: &[&str], longs: I, - subcommands: impl IntoIterator>, + subcommands: impl IntoIterator>, ) -> Option<(String, Option)> where 'help: 'a, diff --git a/src/parse/matches/arg_matches.rs b/src/parse/matches/arg_matches.rs index dbc86b5c21c..6d3329e3f0e 100644 --- a/src/parse/matches/arg_matches.rs +++ b/src/parse/matches/arg_matches.rs @@ -20,14 +20,14 @@ use crate::{Error, INVALID_UTF8}; /// Container for parse results. /// /// Used to get information about the arguments that were supplied to the program at runtime by -/// the user. New instances of this struct are obtained by using the [`App::get_matches`] family of +/// the user. New instances of this struct are obtained by using the [`Command::get_matches`] family of /// methods. /// /// # Examples /// /// ```no_run -/// # use clap::{App, Arg}; -/// let matches = App::new("MyApp") +/// # use clap::{Command, Arg}; +/// let matches = Command::new("MyApp") /// .arg(Arg::new("out") /// .long("output") /// .required(true) @@ -65,7 +65,7 @@ use crate::{Error, INVALID_UTF8}; /// } /// } /// ``` -/// [`App::get_matches`]: crate::App::get_matches() +/// [`Command::get_matches`]: crate::Command::get_matches() #[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct ArgMatches { #[cfg(debug_assertions)] @@ -84,8 +84,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let mut app = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let mut app = Command::new("myapp") /// .arg(Arg::new("output") /// .takes_value(true)); /// @@ -125,8 +125,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("output") /// .takes_value(true)) /// .get_matches_from(vec!["myapp", "something"]); @@ -172,11 +172,11 @@ impl ArgMatches { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::{App, arg}; + /// # use clap::{Command, arg}; /// use std::ffi::OsString; /// use std::os::unix::ffi::{OsStrExt,OsStringExt}; /// - /// let m = App::new("utf8") + /// let m = Command::new("utf8") /// .arg(arg!( "some arg") /// .allow_invalid_utf8(true)) /// .get_matches_from(vec![OsString::from("myprog"), @@ -223,11 +223,11 @@ impl ArgMatches { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::{App, arg}; + /// # use clap::{Command, arg}; /// use std::ffi::OsString; /// use std::os::unix::ffi::{OsStrExt,OsStringExt}; /// - /// let m = App::new("utf8") + /// let m = Command::new("utf8") /// .arg(arg!( "some arg") /// .allow_invalid_utf8(true)) /// .get_matches_from(vec![OsString::from("myprog"), @@ -263,8 +263,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") /// .arg(Arg::new("output") /// .multiple_occurrences(true) /// .short('o') @@ -325,11 +325,11 @@ impl ArgMatches { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::{App, arg}; + /// # use clap::{Command, arg}; /// use std::ffi::OsString; /// use std::os::unix::ffi::OsStringExt; /// - /// let m = App::new("utf8") + /// let m = Command::new("utf8") /// .arg(arg!( ... "some arg") /// .allow_invalid_utf8(true)) /// .get_matches_from(vec![OsString::from("myprog"), @@ -374,11 +374,11 @@ impl ArgMatches { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] - /// # use clap::{App, arg}; + /// # use clap::{Command, arg}; /// use std::ffi::{OsStr,OsString}; /// use std::os::unix::ffi::{OsStrExt,OsStringExt}; /// - /// let m = App::new("utf8") + /// let m = Command::new("utf8") /// .arg(arg!( ... "some arg") /// .allow_invalid_utf8(true)) /// .get_matches_from(vec![OsString::from("myprog"), @@ -430,8 +430,8 @@ impl ArgMatches { /// # Examples /// /// ``` - /// # use clap::{App, arg}; - /// let matches = App::new("myapp") + /// # use clap::{Command, arg}; + /// let matches = Command::new("myapp") /// .arg(arg!([length] "Set the length to use as a pos whole num i.e. 20")) /// .get_matches_from(&["test", "12"]); /// @@ -480,8 +480,8 @@ impl ArgMatches { /// # Examples /// /// ``` - /// # use clap::{App, arg}; - /// let matches = App::new("myapp") + /// # use clap::{Command, arg}; + /// let matches = Command::new("myapp") /// .arg(arg!([length] "Set the length to use as a pos whole num i.e. 20")) /// .get_matches_from(&["test", "12"]); /// @@ -523,8 +523,8 @@ impl ArgMatches { /// # Examples /// /// ``` - /// # use clap::{App, arg}; - /// let matches = App::new("myapp") + /// # use clap::{Command, arg}; + /// let matches = Command::new("myapp") /// .arg(arg!([length] ... "A sequence of integers because integers are neat!")) /// .get_matches_from(&["test", "12", "77", "40"]); /// @@ -570,8 +570,8 @@ impl ArgMatches { /// # Examples /// /// ``` - /// # use clap::{App, arg}; - /// let matches = App::new("myapp") + /// # use clap::{Command, arg}; + /// let matches = Command::new("myapp") /// .arg(arg!([length] ... "A sequence of integers because integers are neat!")) /// .get_matches_from(&["test", "12", "77", "40"]); /// @@ -604,8 +604,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") /// .arg(Arg::new("debug") /// .short('d')) /// .get_matches_from(vec![ @@ -638,8 +638,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") /// .arg(Arg::new("debug") /// .short('d')) /// .get_matches_from(vec![ @@ -674,8 +674,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") /// .arg(Arg::new("debug") /// .short('d') /// .multiple_occurrences(true)) @@ -689,8 +689,8 @@ impl ArgMatches { /// This next example shows that counts actual uses of the argument, not just `-`'s /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myprog") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myprog") /// .arg(Arg::new("debug") /// .short('d') /// .multiple_occurrences(true)) @@ -737,8 +737,8 @@ impl ArgMatches { /// in an `ArgMatches` struct for querying. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("option") @@ -755,8 +755,8 @@ impl ArgMatches { /// Now notice, if we use one of the other styles of options: /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("option") @@ -774,8 +774,8 @@ impl ArgMatches { /// flags. Let's also throw in the final option style for good measure. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("flag2") @@ -800,8 +800,8 @@ impl ArgMatches { /// One final combination of flags/options to see how they combine: /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("flag") /// .short('f')) /// .arg(Arg::new("flag2") @@ -826,8 +826,8 @@ impl ArgMatches { /// The last part to mention is when values are sent in multiple groups with a [delimiter]. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("option") /// .short('o') /// .use_value_delimiter(true) @@ -867,8 +867,8 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("option") /// .short('o') /// .use_value_delimiter(true) @@ -885,8 +885,8 @@ impl ArgMatches { /// Another quick example is when flags and options are used together /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("option") /// .short('o') /// .takes_value(true) @@ -908,8 +908,8 @@ impl ArgMatches { /// index. /// /// ```rust - /// # use clap::{App, Arg}; - /// let m = App::new("myapp") + /// # use clap::{Command, Arg}; + /// let m = Command::new("myapp") /// .arg(Arg::new("option") /// .short('o') /// .takes_value(true) @@ -942,11 +942,11 @@ impl ArgMatches { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let app_m = App::new("git") - /// .subcommand(App::new("clone")) - /// .subcommand(App::new("push")) - /// .subcommand(App::new("commit")) + /// # use clap::{Command, Arg, }; + /// let app_m = Command::new("git") + /// .subcommand(Command::new("clone")) + /// .subcommand(Command::new("push")) + /// .subcommand(Command::new("commit")) /// .get_matches(); /// /// match app_m.subcommand() { @@ -962,9 +962,9 @@ impl ArgMatches { /// with pattern matching! /// /// ```rust - /// # use clap::App; + /// # use clap::Command; /// // Assume there is an external subcommand named "subcmd" - /// let app_m = App::new("myprog") + /// let app_m = Command::new("myprog") /// .allow_external_subcommands(true) /// .get_matches_from(vec![ /// "myprog", "subcmd", "--option", "value", "-fff", "--flag" @@ -981,7 +981,7 @@ impl ArgMatches { /// _ => {}, /// } /// ``` - /// [subcommand]: crate::App::subcommand + /// [subcommand]: crate::Command::subcommand #[inline] pub fn subcommand(&self) -> Option<(&str, &ArgMatches)> { self.subcommand.as_ref().map(|sc| (&*sc.name, &sc.matches)) @@ -1000,11 +1000,11 @@ impl ArgMatches { /// # Examples /// /// ```rust - /// # use clap::{App, Arg, }; - /// let app_m = App::new("myprog") + /// # use clap::{Command, Arg, }; + /// let app_m = Command::new("myprog") /// .arg(Arg::new("debug") /// .short('d')) - /// .subcommand(App::new("test") + /// .subcommand(Command::new("test") /// .arg(Arg::new("opt") /// .long("option") /// .takes_value(true))) @@ -1022,8 +1022,8 @@ impl ArgMatches { /// } /// ``` /// - /// [subcommand]: crate::App::subcommand - /// [`App`]: crate::App + /// [subcommand]: crate::Command::subcommand + /// [`Command`]: crate::Command pub fn subcommand_matches(&self, id: T) -> Option<&ArgMatches> { self.get_subcommand(&id.into()).map(|sc| &sc.matches) } @@ -1035,11 +1035,11 @@ impl ArgMatches { /// # Examples /// /// ```no_run - /// # use clap::{App, Arg, }; - /// let app_m = App::new("git") - /// .subcommand(App::new("clone")) - /// .subcommand(App::new("push")) - /// .subcommand(App::new("commit")) + /// # use clap::{Command, Arg, }; + /// let app_m = Command::new("git") + /// .subcommand(Command::new("clone")) + /// .subcommand(Command::new("push")) + /// .subcommand(Command::new("commit")) /// .get_matches(); /// /// match app_m.subcommand_name() { @@ -1049,8 +1049,8 @@ impl ArgMatches { /// _ => {}, // Either no subcommand or one not tested for... /// } /// ``` - /// [subcommand]: crate::App::subcommand - /// [`App`]: crate::App + /// [subcommand]: crate::Command::subcommand + /// [`Command`]: crate::Command #[inline] pub fn subcommand_name(&self) -> Option<&str> { self.subcommand.as_ref().map(|sc| &*sc.name) @@ -1167,8 +1167,8 @@ pub(crate) struct SubCommand { /// # Examples /// /// ```rust -/// # use clap::{App, Arg}; -/// let m = App::new("myapp") +/// # use clap::{Command, Arg}; +/// let m = Command::new("myapp") /// .arg(Arg::new("output") /// .short('o') /// .multiple_occurrences(true) @@ -1264,11 +1264,11 @@ impl<'a> Default for GroupedValues<'a> { /// #[cfg_attr(not(unix), doc = " ```ignore")] #[cfg_attr(unix, doc = " ```")] -/// # use clap::{App, arg}; +/// # use clap::{Command, arg}; /// use std::ffi::OsString; /// use std::os::unix::ffi::{OsStrExt,OsStringExt}; /// -/// let m = App::new("utf8") +/// let m = Command::new("utf8") /// .arg(arg!( "some arg") /// .allow_invalid_utf8(true)) /// .get_matches_from(vec![OsString::from("myprog"), @@ -1320,8 +1320,8 @@ impl Default for OsValues<'_> { /// # Examples /// /// ```rust -/// # use clap::{App, Arg}; -/// let m = App::new("myapp") +/// # use clap::{Command, Arg}; +/// let m = Command::new("myapp") /// .arg(Arg::new("output") /// .short('o') /// .multiple_values(true) @@ -1438,7 +1438,7 @@ mod tests { #[test] fn values_exact_size() { - let l = crate::App::new("test") + let l = crate::Command::new("test") .arg( crate::Arg::new("POTATO") .takes_value(true) @@ -1455,7 +1455,7 @@ mod tests { #[test] fn os_values_exact_size() { - let l = crate::App::new("test") + let l = crate::Command::new("test") .arg( crate::Arg::new("POTATO") .takes_value(true) @@ -1473,7 +1473,7 @@ mod tests { #[test] fn indices_exact_size() { - let l = crate::App::new("test") + let l = crate::Command::new("test") .arg( crate::Arg::new("POTATO") .takes_value(true) diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 980b2615094..de37c4e9b39 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -9,7 +9,7 @@ use os_str_bytes::RawOsStr; // Internal use crate::build::AppSettings as AS; -use crate::build::{App, Arg}; +use crate::build::{Arg, Command}; use crate::error::Error as ClapError; use crate::error::Result as ClapResult; use crate::mkeymap::KeyType; @@ -21,7 +21,7 @@ use crate::util::{color::ColorChoice, Id}; use crate::{INTERNAL_ERROR_MSG, INVALID_UTF8}; pub(crate) struct Parser<'help, 'app> { - pub(crate) app: &'app mut App<'help>, + pub(crate) app: &'app mut Command<'help>, pub(crate) overridden: RefCell>, seen: Vec, cur_idx: Cell, @@ -34,7 +34,7 @@ pub(crate) struct Parser<'help, 'app> { // Initializing Methods impl<'help, 'app> Parser<'help, 'app> { - pub(crate) fn new(app: &'app mut App<'help>) -> Self { + pub(crate) fn new(app: &'app mut Command<'help>) -> Self { Parser { app, overridden: Default::default(), diff --git a/src/parse/validator.rs b/src/parse/validator.rs index 712f6dbbfde..4df9c41ca4a 100644 --- a/src/parse/validator.rs +++ b/src/parse/validator.rs @@ -1,5 +1,5 @@ // Internal -use crate::build::{App, AppSettings, Arg, ArgPredicate, PossibleValue}; +use crate::build::{AppSettings, Arg, ArgPredicate, Command, PossibleValue}; use crate::error::{Error, Result as ClapResult}; use crate::output::Usage; use crate::parse::{ArgMatcher, MatchedArg, ParseState, Parser}; @@ -608,7 +608,7 @@ impl Conflicts { Self::default() } - fn gather_conflicts(&mut self, app: &App, matcher: &ArgMatcher, arg_id: &Id) -> Vec { + fn gather_conflicts(&mut self, app: &Command, matcher: &ArgMatcher, arg_id: &Id) -> Vec { debug!("Conflicts::gather_conflicts"); let mut conflicts = Vec::new(); for other_arg_id in matcher @@ -635,7 +635,7 @@ impl Conflicts { conflicts } - fn gather_direct_conflicts(&mut self, app: &App, arg_id: &Id) -> &[Id] { + fn gather_direct_conflicts(&mut self, app: &Command, arg_id: &Id) -> &[Id] { self.potential.entry(arg_id.clone()).or_insert_with(|| { let conf = if let Some(arg) = app.find(arg_id) { let mut conf = arg.blacklist.clone(); diff --git a/src/util/color.rs b/src/util/color.rs index 272a6c91688..15c9901a079 100644 --- a/src/util/color.rs +++ b/src/util/color.rs @@ -13,8 +13,8 @@ pub enum ColorChoice { /// #[cfg_attr(not(feature = "color"), doc = " ```ignore")] #[cfg_attr(feature = "color", doc = " ```no_run")] - /// # use clap::{App, ColorChoice}; - /// App::new("myprog") + /// # use clap::{Command, ColorChoice}; + /// Command::new("myprog") /// .color(ColorChoice::Auto) /// .get_matches(); /// ``` @@ -30,8 +30,8 @@ pub enum ColorChoice { /// #[cfg_attr(not(feature = "color"), doc = " ```ignore")] #[cfg_attr(feature = "color", doc = " ```no_run")] - /// # use clap::{App, ColorChoice}; - /// App::new("myprog") + /// # use clap::{Command, ColorChoice}; + /// Command::new("myprog") /// .color(ColorChoice::Always) /// .get_matches(); /// ``` @@ -47,8 +47,8 @@ pub enum ColorChoice { /// #[cfg_attr(not(feature = "color"), doc = " ```ignore")] #[cfg_attr(feature = "color", doc = " ```no_run")] - /// # use clap::{App, ColorChoice}; - /// App::new("myprog") + /// # use clap::{Command, ColorChoice}; + /// Command::new("myprog") /// .color(ColorChoice::Never) /// .get_matches(); /// ``` diff --git a/tests/builder/app_settings.rs b/tests/builder/app_settings.rs index d7252cf1749..d0dbf585485 100644 --- a/tests/builder/app_settings.rs +++ b/tests/builder/app_settings.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, AppSettings, Arg}; +use clap::{arg, error::ErrorKind, AppSettings, Arg, Command}; static ALLOW_EXT_SC: &str = "clap-test v1.4.8 @@ -82,21 +82,21 @@ SUBCOMMANDS: #[test] fn setting() { #![allow(deprecated)] - let m = App::new("setting").args_override_self(true); + let m = Command::new("setting").args_override_self(true); assert!(m.is_set(AppSettings::AllArgsOverrideSelf)); } #[test] fn global_setting() { #![allow(deprecated)] - let m = App::new("global_setting").args_override_self(true); + let m = Command::new("global_setting").args_override_self(true); assert!(m.is_set(AppSettings::AllArgsOverrideSelf)); } #[test] fn unset_setting() { #![allow(deprecated)] - let m = App::new("unset_setting").args_override_self(true); + let m = Command::new("unset_setting").args_override_self(true); assert!(m.is_set(AppSettings::AllArgsOverrideSelf)); let m = m.args_override_self(false); @@ -106,7 +106,7 @@ fn unset_setting() { #[test] fn unset_global_setting() { #![allow(deprecated)] - let m = App::new("unset_global_setting").args_override_self(true); + let m = Command::new("unset_global_setting").args_override_self(true); assert!(m.is_set(AppSettings::AllArgsOverrideSelf)); let m = m.args_override_self(false); @@ -116,7 +116,7 @@ fn unset_global_setting() { #[test] fn setting_bitor() { #![allow(deprecated)] - let m = App::new("setting_bitor").setting( + let m = Command::new("setting_bitor").setting( AppSettings::InferSubcommands | AppSettings::Hidden | AppSettings::DisableHelpSubcommand, ); @@ -128,7 +128,7 @@ fn setting_bitor() { #[test] fn unset_setting_bitor() { #![allow(deprecated)] - let m = App::new("unset_setting_bitor") + let m = Command::new("unset_setting_bitor") .setting(AppSettings::InferSubcommands) .setting(AppSettings::Hidden) .setting(AppSettings::DisableHelpSubcommand); @@ -147,20 +147,20 @@ fn unset_setting_bitor() { #[test] fn sub_command_negate_required() { - App::new("sub_command_negate") + Command::new("sub_command_negate") .subcommand_negates_reqs(true) .arg(Arg::new("test").required(true).index(1)) - .subcommand(App::new("sub1")) + .subcommand(Command::new("sub1")) .try_get_matches_from(vec!["myprog", "sub1"]) .unwrap(); } #[test] fn sub_command_negate_required_2() { - let result = App::new("sub_command_negate") + let result = Command::new("sub_command_negate") .subcommand_negates_reqs(true) .arg(Arg::new("test").required(true).index(1)) - .subcommand(App::new("sub1")) + .subcommand(Command::new("sub1")) .try_get_matches_from(vec![""]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -169,9 +169,9 @@ fn sub_command_negate_required_2() { #[test] fn sub_command_required() { - let result = App::new("sc_required") + let result = Command::new("sc_required") .subcommand_required(true) - .subcommand(App::new("sub1")) + .subcommand(Command::new("sub1")) .try_get_matches_from(vec![""]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -180,7 +180,7 @@ fn sub_command_required() { #[test] fn arg_required_else_help() { - let result = App::new("arg_required") + let result = Command::new("arg_required") .arg_required_else_help(true) .arg(Arg::new("test").index(1)) .try_get_matches_from(vec![""]); @@ -195,7 +195,7 @@ fn arg_required_else_help() { #[test] fn arg_required_else_help_over_req_arg() { - let result = App::new("arg_required") + let result = Command::new("arg_required") .arg_required_else_help(true) .arg(Arg::new("test").index(1).required(true)) .try_get_matches_from(vec![""]); @@ -210,10 +210,10 @@ fn arg_required_else_help_over_req_arg() { #[test] fn arg_required_else_help_over_req_subcommand() { - let result = App::new("sub_required") + let result = Command::new("sub_required") .arg_required_else_help(true) .subcommand_required(true) - .subcommand(App::new("sub1")) + .subcommand(Command::new("sub1")) .try_get_matches_from(vec![""]); assert!(result.is_err()); @@ -226,7 +226,7 @@ fn arg_required_else_help_over_req_subcommand() { #[test] fn arg_required_else_help_with_default() { - let result = App::new("arg_required") + let result = Command::new("arg_required") .arg_required_else_help(true) .arg(arg!(--input ).required(false).default_value("-")) .try_get_matches_from(vec![""]); @@ -241,7 +241,7 @@ fn arg_required_else_help_with_default() { #[test] fn arg_required_else_help_error_message() { - let app = App::new("test") + let app = Command::new("test") .arg_required_else_help(true) .version("1.0") .arg( @@ -261,9 +261,9 @@ fn arg_required_else_help_error_message() { #[test] fn subcommand_required_else_help() { #![allow(deprecated)] - let result = App::new("test") + let result = Command::new("test") .setting(AppSettings::SubcommandRequiredElseHelp) - .subcommand(App::new("info")) + .subcommand(Command::new("info")) .try_get_matches_from(&[""]); assert!(result.is_err()); @@ -277,10 +277,10 @@ fn subcommand_required_else_help() { #[test] fn subcommand_required_else_help_error_message() { #![allow(deprecated)] - let app = App::new("test") + let app = Command::new("test") .setting(AppSettings::SubcommandRequiredElseHelp) .version("1.0") - .subcommand(App::new("info").arg(Arg::new("filename"))); + .subcommand(Command::new("info").arg(Arg::new("filename"))); assert!(utils::compare_output( app, "test", @@ -292,10 +292,10 @@ fn subcommand_required_else_help_error_message() { #[cfg(not(feature = "suggestions"))] #[test] fn infer_subcommands_fail_no_args() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "te"]); assert!(m.is_err(), "{:#?}", m.unwrap()); assert_eq!(m.unwrap_err().kind(), ErrorKind::UnrecognizedSubcommand); @@ -304,10 +304,10 @@ fn infer_subcommands_fail_no_args() { #[cfg(feature = "suggestions")] #[test] fn infer_subcommands_fail_no_args() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "te"]); assert!(m.is_err(), "{:#?}", m.unwrap()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidSubcommand); @@ -315,11 +315,11 @@ fn infer_subcommands_fail_no_args() { #[test] fn infer_subcommands_fail_with_args() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) .arg(Arg::new("some")) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "t"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind()); assert_eq!(m.unwrap().value_of("some"), Some("t")); @@ -327,11 +327,11 @@ fn infer_subcommands_fail_with_args() { #[test] fn infer_subcommands_fail_with_args2() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) .arg(Arg::new("some")) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "te"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind()); assert_eq!(m.unwrap().value_of("some"), Some("te")); @@ -339,9 +339,9 @@ fn infer_subcommands_fail_with_args2() { #[test] fn infer_subcommands_pass() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) + .subcommand(Command::new("test")) .try_get_matches_from(vec!["prog", "te"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("test")); @@ -349,10 +349,10 @@ fn infer_subcommands_pass() { #[test] fn infer_subcommands_pass_close() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "tes"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("test")); @@ -360,11 +360,11 @@ fn infer_subcommands_pass_close() { #[test] fn infer_subcommands_pass_exact_match() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) - .subcommand(App::new("testa")) - .subcommand(App::new("testb")) + .subcommand(Command::new("test")) + .subcommand(Command::new("testa")) + .subcommand(Command::new("testb")) .try_get_matches_from(vec!["prog", "test"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("test")); @@ -373,10 +373,10 @@ fn infer_subcommands_pass_exact_match() { #[cfg(feature = "suggestions")] #[test] fn infer_subcommands_fail_suggestions() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "temps"]); assert!(m.is_err(), "{:#?}", m.unwrap()); assert_eq!(m.unwrap_err().kind(), ErrorKind::InvalidSubcommand); @@ -385,10 +385,10 @@ fn infer_subcommands_fail_suggestions() { #[cfg(not(feature = "suggestions"))] #[test] fn infer_subcommands_fail_suggestions() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test")) - .subcommand(App::new("temp")) + .subcommand(Command::new("test")) + .subcommand(Command::new("temp")) .try_get_matches_from(vec!["prog", "temps"]); assert!(m.is_err(), "{:#?}", m.unwrap()); assert_eq!(m.unwrap_err().kind(), ErrorKind::UnrecognizedSubcommand); @@ -396,7 +396,7 @@ fn infer_subcommands_fail_suggestions() { #[test] fn no_bin_name() { - let result = App::new("arg_required") + let result = Command::new("arg_required") .no_binary_name(true) .arg(Arg::new("test").required(true).index(1)) .try_get_matches_from(vec!["testing"]); @@ -407,7 +407,7 @@ fn no_bin_name() { #[test] fn skip_possible_values() { - let app = App::new("test") + let app = Command::new("test") .author("Kevin K.") .about("tests stuff") .version("1.3") @@ -429,7 +429,7 @@ fn skip_possible_values() { #[test] fn stop_delim_values_only_pos_follows() { - let r = App::new("onlypos") + let r = Command::new("onlypos") .dont_delimit_trailing_values(true) .args(&[ arg!(f: -f "some opt").required(false), @@ -448,7 +448,7 @@ fn stop_delim_values_only_pos_follows() { #[test] fn dont_delim_values_trailingvararg() { - let m = App::new("positional") + let m = Command::new("positional") .trailing_var_arg(true) .dont_delimit_trailing_values(true) .arg(arg!([opt] ... "some pos")) @@ -463,7 +463,7 @@ fn dont_delim_values_trailingvararg() { #[test] fn delim_values_only_pos_follows() { - let r = App::new("onlypos") + let r = Command::new("onlypos") .args(&[arg!(f: -f [flag] "some opt"), arg!([arg] ... "some arg")]) .try_get_matches_from(vec!["", "--", "-f", "-g,x"]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -478,7 +478,7 @@ fn delim_values_only_pos_follows() { #[test] fn delim_values_trailingvararg() { - let m = App::new("positional") + let m = Command::new("positional") .trailing_var_arg(true) .arg(arg!([opt] ... "some pos")) .try_get_matches_from(vec!["", "test", "--foo", "-Wl,-bar"]) @@ -492,7 +492,7 @@ fn delim_values_trailingvararg() { #[test] fn delim_values_only_pos_follows_with_delim() { - let r = App::new("onlypos") + let r = Command::new("onlypos") .args(&[ arg!(f: -f [flag] "some opt"), arg!([arg] ... "some arg").use_value_delimiter(true), @@ -510,7 +510,7 @@ fn delim_values_only_pos_follows_with_delim() { #[test] fn delim_values_trailingvararg_with_delim() { - let m = App::new("positional") + let m = Command::new("positional") .trailing_var_arg(true) .arg(arg!([opt] ... "some pos").use_value_delimiter(true)) .try_get_matches_from(vec!["", "test", "--foo", "-Wl,-bar"]) @@ -524,7 +524,7 @@ fn delim_values_trailingvararg_with_delim() { #[test] fn leading_hyphen_short() { - let res = App::new("leadhy") + let res = Command::new("leadhy") .allow_hyphen_values(true) .arg(Arg::new("some")) .arg(Arg::new("other").short('o')) @@ -538,7 +538,7 @@ fn leading_hyphen_short() { #[test] fn leading_hyphen_long() { - let res = App::new("leadhy") + let res = Command::new("leadhy") .allow_hyphen_values(true) .arg(Arg::new("some")) .arg(Arg::new("other").short('o')) @@ -552,7 +552,7 @@ fn leading_hyphen_long() { #[test] fn leading_hyphen_opt() { - let res = App::new("leadhy") + let res = Command::new("leadhy") .allow_hyphen_values(true) .arg(Arg::new("some").takes_value(true).long("opt")) .arg(Arg::new("other").short('o')) @@ -566,7 +566,7 @@ fn leading_hyphen_opt() { #[test] fn allow_negative_numbers() { - let res = App::new("negnum") + let res = Command::new("negnum") .allow_negative_numbers(true) .arg(Arg::new("panum")) .arg(Arg::new("onum").short('o').takes_value(true)) @@ -579,7 +579,7 @@ fn allow_negative_numbers() { #[test] fn allow_negative_numbers_fail() { - let res = App::new("negnum") + let res = Command::new("negnum") .allow_negative_numbers(true) .arg(Arg::new("panum")) .arg(Arg::new("onum").short('o').takes_value(true)) @@ -590,7 +590,7 @@ fn allow_negative_numbers_fail() { #[test] fn leading_double_hyphen_trailingvararg() { - let m = App::new("positional") + let m = Command::new("positional") .trailing_var_arg(true) .allow_hyphen_values(true) .arg(arg!([opt] ... "some pos")) @@ -605,9 +605,9 @@ fn leading_double_hyphen_trailingvararg() { #[test] fn disable_help_subcommand() { - let result = App::new("disablehelp") + let result = Command::new("disablehelp") .disable_help_subcommand(true) - .subcommand(App::new("sub1")) + .subcommand(Command::new("sub1")) .try_get_matches_from(vec!["", "help"]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -616,7 +616,7 @@ fn disable_help_subcommand() { #[test] fn dont_collapse_args() { - let app = App::new("clap-test") + let app = Command::new("clap-test") .version("v1.4.8") .dont_collapse_args_in_usage(true) .args(&[ @@ -634,7 +634,7 @@ fn dont_collapse_args() { #[test] fn require_eq() { - let app = App::new("clap-test").version("v1.4.8").arg( + let app = Command::new("clap-test").version("v1.4.8").arg( Arg::new("opt") .long("opt") .short('o') @@ -653,12 +653,14 @@ fn require_eq() { #[test] fn args_negate_subcommands_one_level() { - let res = App::new("disablehelp") + let res = Command::new("disablehelp") .args_conflicts_with_subcommands(true) .subcommand_negates_reqs(true) .arg(arg!( "some arg")) .arg(arg!( "some arg")) - .subcommand(App::new("sub1").subcommand(App::new("sub2").subcommand(App::new("sub3")))) + .subcommand( + Command::new("sub1").subcommand(Command::new("sub2").subcommand(Command::new("sub3"))), + ) .try_get_matches_from(vec!["", "pickles", "sub1"]); assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind()); let m = res.unwrap(); @@ -667,18 +669,18 @@ fn args_negate_subcommands_one_level() { #[test] fn args_negate_subcommands_two_levels() { - let res = App::new("disablehelp") + let res = Command::new("disablehelp") .args_conflicts_with_subcommands(true) .subcommand_negates_reqs(true) .arg(arg!( "some arg")) .arg(arg!( "some arg")) .subcommand( - App::new("sub1") + Command::new("sub1") .args_conflicts_with_subcommands(true) .subcommand_negates_reqs(true) .arg(arg!( "some")) .arg(arg!( "some")) - .subcommand(App::new("sub2").subcommand(App::new("sub3"))), + .subcommand(Command::new("sub2").subcommand(Command::new("sub3"))), ) .try_get_matches_from(vec!["", "sub1", "arg", "sub2"]); assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind()); @@ -691,9 +693,9 @@ fn args_negate_subcommands_two_levels() { #[test] fn propagate_vals_down() { - let m = App::new("myprog") + let m = Command::new("myprog") .arg(arg!([cmd] "command to run").global(true)) - .subcommand(App::new("foo")) + .subcommand(Command::new("foo")) .try_get_matches_from(vec!["myprog", "set", "foo"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind()); let m = m.unwrap(); @@ -704,7 +706,7 @@ fn propagate_vals_down() { #[test] fn allow_missing_positional() { - let m = App::new("test") + let m = Command::new("test") .allow_missing_positional(true) .arg(arg!([src] "some file").default_value("src")) .arg(arg!( "some file")) @@ -717,7 +719,7 @@ fn allow_missing_positional() { #[test] fn allow_missing_positional_no_default() { - let m = App::new("test") + let m = Command::new("test") .allow_missing_positional(true) .arg(arg!([src] "some file")) .arg(arg!( "some file")) @@ -730,7 +732,7 @@ fn allow_missing_positional_no_default() { #[test] fn missing_positional_no_hyphen() { - let r = App::new("bench") + let r = Command::new("bench") .allow_missing_positional(true) .arg(arg!([BENCH] "some bench")) .arg(arg!([ARGS] ... "some args")) @@ -751,7 +753,7 @@ fn missing_positional_no_hyphen() { #[test] fn missing_positional_hyphen() { - let r = App::new("bench") + let r = Command::new("bench") .allow_missing_positional(true) .arg(arg!([BENCH] "some bench")) .arg(arg!([ARGS] ... "some args")) @@ -772,7 +774,7 @@ fn missing_positional_hyphen() { #[test] fn missing_positional_hyphen_far_back() { - let r = App::new("bench") + let r = Command::new("bench") .allow_missing_positional(true) .arg(arg!([BENCH1] "some bench")) .arg(arg!([BENCH2] "some bench")) @@ -799,7 +801,7 @@ fn missing_positional_hyphen_far_back() { #[test] fn missing_positional_hyphen_req_error() { - let r = App::new("bench") + let r = Command::new("bench") .allow_missing_positional(true) .arg(arg!([BENCH1] "some bench")) .arg(arg!( "some bench")) @@ -811,7 +813,7 @@ fn missing_positional_hyphen_req_error() { #[test] fn issue_1066_allow_leading_hyphen_and_unknown_args() { - let res = App::new("prog") + let res = Command::new("prog") .allow_hyphen_values(true) .arg(arg!(--"some-argument")) .try_get_matches_from(vec!["prog", "hello"]); @@ -822,7 +824,7 @@ fn issue_1066_allow_leading_hyphen_and_unknown_args() { #[test] fn issue_1066_allow_leading_hyphen_and_unknown_args_no_vals() { - let res = App::new("prog") + let res = Command::new("prog") .allow_hyphen_values(true) .arg(arg!(--"some-argument")) .try_get_matches_from(vec!["prog", "--hello"]); @@ -833,7 +835,7 @@ fn issue_1066_allow_leading_hyphen_and_unknown_args_no_vals() { #[test] fn issue_1066_allow_leading_hyphen_and_unknown_args_option() { - let res = App::new("prog") + let res = Command::new("prog") .allow_hyphen_values(true) .arg(arg!(--"some-argument" )) .try_get_matches_from(vec!["prog", "-hello"]); @@ -844,7 +846,7 @@ fn issue_1066_allow_leading_hyphen_and_unknown_args_option() { #[test] fn issue_1437_allow_hyphen_values_for_positional_arg() { - let m = App::new("tmp") + let m = Command::new("tmp") .arg( Arg::new("pat") .allow_hyphen_values(true) @@ -858,7 +860,7 @@ fn issue_1437_allow_hyphen_values_for_positional_arg() { #[test] fn issue_1093_allow_ext_sc() { - let app = App::new("clap-test") + let app = Command::new("clap-test") .version("v1.4.8") .allow_external_subcommands(true); assert!(utils::compare_output( @@ -871,7 +873,7 @@ fn issue_1093_allow_ext_sc() { #[test] fn allow_ext_sc_when_sc_required() { - let res = App::new("clap-test") + let res = Command::new("clap-test") .version("v1.4.8") .allow_external_subcommands(true) .allow_invalid_utf8_for_external_subcommands(true) @@ -891,11 +893,11 @@ fn allow_ext_sc_when_sc_required() { #[test] fn external_subcommand_looks_like_built_in() { - let res = App::new("cargo") + let res = Command::new("cargo") .version("1.26.0") .allow_external_subcommands(true) .allow_invalid_utf8_for_external_subcommands(true) - .subcommand(App::new("install")) + .subcommand(Command::new("install")) .try_get_matches_from(vec!["cargo", "install-update", "foo"]); assert!(res.is_ok(), "{}", res.unwrap_err()); let m = res.unwrap(); @@ -911,7 +913,7 @@ fn external_subcommand_looks_like_built_in() { #[test] fn aaos_flags() { // flags - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!(--flag "some flag")) .try_get_matches_from(vec!["", "--flag", "--flag"]); @@ -924,7 +926,7 @@ fn aaos_flags() { #[test] fn aaos_flags_mult() { // flags with multiple - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!(--flag ... "some flag")) .try_get_matches_from(vec!["", "--flag", "--flag", "--flag", "--flag"]); @@ -937,7 +939,7 @@ fn aaos_flags_mult() { #[test] fn aaos_opts() { // opts - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!(--opt "some option")) .try_get_matches_from(vec!["", "--opt=some", "--opt=other"]); @@ -951,7 +953,7 @@ fn aaos_opts() { #[test] fn aaos_opts_w_other_overrides() { // opts with other overrides - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!(--opt "some option").required(false)) .arg( @@ -971,7 +973,7 @@ fn aaos_opts_w_other_overrides() { #[test] fn aaos_opts_w_other_overrides_rev() { // opts with other overrides, rev - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!(--opt "some option").required(true)) .arg( @@ -990,7 +992,7 @@ fn aaos_opts_w_other_overrides_rev() { #[test] fn aaos_opts_w_other_overrides_2() { // opts with other overrides - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg( arg!(--opt "some option") @@ -1010,7 +1012,7 @@ fn aaos_opts_w_other_overrides_2() { #[test] fn aaos_opts_w_other_overrides_rev_2() { // opts with other overrides, rev - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg( arg!(--opt "some option") @@ -1029,7 +1031,7 @@ fn aaos_opts_w_other_overrides_rev_2() { #[test] fn aaos_opts_mult() { // opts with multiple - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg( arg!(--opt ... "some option") @@ -1052,7 +1054,7 @@ fn aaos_opts_mult() { #[test] fn aaos_opts_mult_req_delims() { // opts with multiple and require delims - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!(--opt ... "some option").multiple_values(true)) .try_get_matches_from(vec![ @@ -1078,7 +1080,7 @@ fn aaos_opts_mult_req_delims() { #[test] fn aaos_pos_mult() { // opts with multiple - let res = App::new("posix") + let res = Command::new("posix") .args_override_self(true) .arg(arg!([val] ... "some pos")) .try_get_matches_from(vec!["", "some", "other", "value"]); @@ -1094,7 +1096,7 @@ fn aaos_pos_mult() { #[test] fn aaos_option_use_delim_false() { - let m = App::new("posix") + let m = Command::new("posix") .args_override_self(true) .arg(arg!(--opt "some option").use_value_delimiter(false)) .try_get_matches_from(vec!["", "--opt=some,other", "--opt=one,two"]) @@ -1109,9 +1111,9 @@ fn aaos_option_use_delim_false() { #[test] fn no_auto_help() { - let app = App::new("myprog") + let app = Command::new("myprog") .setting(AppSettings::NoAutoHelp) - .subcommand(App::new("foo")); + .subcommand(Command::new("foo")); let result = app.clone().try_get_matches_from("myprog --help".split(' ')); @@ -1131,7 +1133,7 @@ fn no_auto_help() { #[test] fn no_auto_version() { - let app = App::new("myprog") + let app = Command::new("myprog") .version("3.0") .setting(AppSettings::NoAutoVersion); @@ -1150,7 +1152,7 @@ fn no_auto_version() { #[test] fn no_auto_version_mut_arg() { - let app = App::new("myprog") + let app = Command::new("myprog") .version("3.0") .mut_arg("version", |v| v.help("custom help")) .setting(AppSettings::NoAutoVersion); @@ -1171,9 +1173,9 @@ fn no_auto_version_mut_arg() { #[test] #[cfg(feature = "color")] fn color_is_global() { - let mut app = App::new("myprog") + let mut app = Command::new("myprog") .color(clap::ColorChoice::Never) - .subcommand(App::new("foo")); + .subcommand(Command::new("foo")); app._build_all(); assert_eq!(app.get_color(), clap::ColorChoice::Never); diff --git a/tests/builder/arg_aliases.rs b/tests/builder/arg_aliases.rs index 3800fa80885..aa06debec21 100644 --- a/tests/builder/arg_aliases.rs +++ b/tests/builder/arg_aliases.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; static SC_VISIBLE_ALIAS_HELP: &str = "ct-test 1.2 Some help @@ -30,7 +30,7 @@ OPTIONS: #[test] fn single_alias_of_option() { - let a = App::new("single_alias") + let a = Command::new("single_alias") .arg( Arg::new("alias") .long("alias") @@ -47,7 +47,7 @@ fn single_alias_of_option() { #[test] fn multiple_aliases_of_option() { - let a = App::new("multiple_aliases").arg( + let a = Command::new("multiple_aliases").arg( Arg::new("aliases") .long("aliases") .takes_value(true) @@ -90,7 +90,7 @@ fn multiple_aliases_of_option() { #[test] fn single_alias_of_flag() { - let a = App::new("test") + let a = Command::new("test") .arg(Arg::new("flag").long("flag").alias("alias")) .try_get_matches_from(vec!["", "--alias"]); assert!(a.is_ok(), "{}", a.unwrap_err()); @@ -100,7 +100,7 @@ fn single_alias_of_flag() { #[test] fn multiple_aliases_of_flag() { - let a = App::new("test").arg(Arg::new("flag").long("flag").aliases(&[ + let a = Command::new("test").arg(Arg::new("flag").long("flag").aliases(&[ "invisible", "set", "of", @@ -132,9 +132,9 @@ fn multiple_aliases_of_flag() { #[test] fn alias_on_a_subcommand_option() { - let m = App::new("test") + let m = Command::new("test") .subcommand( - App::new("some").arg( + Command::new("some").arg( Arg::new("test") .short('t') .long("test") @@ -155,8 +155,8 @@ fn alias_on_a_subcommand_option() { #[test] fn invisible_arg_aliases_help_output() { - let app = App::new("ct").author("Salim Afiune").subcommand( - App::new("test") + let app = Command::new("ct").author("Salim Afiune").subcommand( + Command::new("test") .about("Some help") .version("1.2") .arg( @@ -178,8 +178,8 @@ fn invisible_arg_aliases_help_output() { #[test] fn visible_arg_aliases_help_output() { - let app = App::new("ct").author("Salim Afiune").subcommand( - App::new("test") + let app = Command::new("ct").author("Salim Afiune").subcommand( + Command::new("test") .about("Some help") .version("1.2") .arg( diff --git a/tests/builder/arg_aliases_short.rs b/tests/builder/arg_aliases_short.rs index 0b0fc30516e..bc90abf5321 100644 --- a/tests/builder/arg_aliases_short.rs +++ b/tests/builder/arg_aliases_short.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; static SC_VISIBLE_ALIAS_HELP: &str = "ct-test 1.2 Some help @@ -30,7 +30,7 @@ OPTIONS: #[test] fn single_short_alias_of_option() { - let a = App::new("single_alias") + let a = Command::new("single_alias") .arg( Arg::new("alias") .long("alias") @@ -47,7 +47,7 @@ fn single_short_alias_of_option() { #[test] fn multiple_short_aliases_of_option() { - let a = App::new("multiple_aliases").arg( + let a = Command::new("multiple_aliases").arg( Arg::new("aliases") .long("aliases") .takes_value(true) @@ -84,7 +84,7 @@ fn multiple_short_aliases_of_option() { #[test] fn single_short_alias_of_flag() { - let a = App::new("test") + let a = Command::new("test") .arg(Arg::new("flag").long("flag").short_alias('f')) .try_get_matches_from(vec!["", "-f"]); assert!(a.is_ok(), "{}", a.unwrap_err()); @@ -94,7 +94,7 @@ fn single_short_alias_of_flag() { #[test] fn multiple_short_aliases_of_flag() { - let a = App::new("test").arg( + let a = Command::new("test").arg( Arg::new("flag") .long("flag") .short_aliases(&['a', 'b', 'c', 'd', 'e']), @@ -124,9 +124,9 @@ fn multiple_short_aliases_of_flag() { #[test] fn short_alias_on_a_subcommand_option() { - let m = App::new("test") + let m = Command::new("test") .subcommand( - App::new("some").arg( + Command::new("some").arg( Arg::new("test") .short('t') .long("test") @@ -151,8 +151,8 @@ fn short_alias_on_a_subcommand_option() { #[test] fn invisible_short_arg_aliases_help_output() { - let app = App::new("ct").author("Salim Afiune").subcommand( - App::new("test") + let app = Command::new("ct").author("Salim Afiune").subcommand( + Command::new("test") .about("Some help") .version("1.2") .arg( @@ -174,8 +174,8 @@ fn invisible_short_arg_aliases_help_output() { #[test] fn visible_short_arg_aliases_help_output() { - let app = App::new("ct").author("Salim Afiune").subcommand( - App::new("test") + let app = Command::new("ct").author("Salim Afiune").subcommand( + Command::new("test") .about("Some help") .version("1.2") .arg( diff --git a/tests/builder/arg_matcher_assertions.rs b/tests/builder/arg_matcher_assertions.rs index fc87b29fffb..e2c2378e8f0 100644 --- a/tests/builder/arg_matcher_assertions.rs +++ b/tests/builder/arg_matcher_assertions.rs @@ -1,11 +1,11 @@ #[cfg(debug_assertions)] -use clap::{App, Arg}; +use clap::{Arg, Command}; #[test] #[cfg(debug_assertions)] #[should_panic = "`f` is not a name of an argument or a group."] fn arg_matches_if_present_wrong_arg() { - let m = App::new("test") + let m = Command::new("test") .arg(Arg::new("flag").short('f')) .try_get_matches_from(&["test", "-f"]) .unwrap(); @@ -18,7 +18,7 @@ fn arg_matches_if_present_wrong_arg() { #[cfg(debug_assertions)] #[should_panic = "`o` is not a name of an argument or a group."] fn arg_matches_value_of_wrong_arg() { - let m = App::new("test") + let m = Command::new("test") .arg(Arg::new("opt").short('o').takes_value(true)) .try_get_matches_from(&["test", "-o", "val"]) .unwrap(); @@ -31,8 +31,8 @@ fn arg_matches_value_of_wrong_arg() { #[cfg(debug_assertions)] #[should_panic = "`seed` is not a name of a subcommand."] fn arg_matches_subcommand_matches_wrong_sub() { - let m = App::new("test") - .subcommand(App::new("speed")) + let m = Command::new("test") + .subcommand(Command::new("speed")) .try_get_matches_from(&["test", "speed"]) .unwrap(); diff --git a/tests/builder/borrowed.rs b/tests/builder/borrowed.rs index c1e668052db..4b4cd39a2d2 100644 --- a/tests/builder/borrowed.rs +++ b/tests/builder/borrowed.rs @@ -1,4 +1,4 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; #[test] fn borrowed_args() { @@ -7,11 +7,11 @@ fn borrowed_args() { .short('S') .long("some-thing") .help("other help"); - let result = App::new("sub_command_negate") + let result = Command::new("sub_command_negate") .arg(Arg::new("test").index(1)) .arg(&arg) .arg(&arg2) - .subcommand(App::new("sub1").arg(&arg)) + .subcommand(Command::new("sub1").arg(&arg)) .try_get_matches_from(vec!["prog"]); assert!(result.is_ok(), "{}", result.unwrap_err()); } diff --git a/tests/builder/cargo.rs b/tests/builder/cargo.rs index 996a9d2fd5a..d2eb6822fa6 100644 --- a/tests/builder/cargo.rs +++ b/tests/builder/cargo.rs @@ -1,6 +1,8 @@ #![cfg(feature = "cargo")] -use clap::{crate_authors, crate_description, crate_name, crate_version, error::ErrorKind, App}; +use clap::{ + crate_authors, crate_description, crate_name, crate_version, error::ErrorKind, Command, +}; static DESCRIPTION_ONLY: &str = "prog 1 A simple to use, efficient, and full-featured Command Line Argument Parser @@ -26,7 +28,7 @@ OPTIONS: #[test] fn crate_version() { - let res = App::new("prog") + let res = Command::new("prog") .version(crate_version!()) .try_get_matches_from(vec!["prog", "--version"]); @@ -41,7 +43,7 @@ fn crate_version() { #[test] fn crate_description() { - let res = App::new("prog") + let res = Command::new("prog") .version("1") .about(crate_description!()) .try_get_matches_from(vec!["prog", "--help"]); @@ -54,7 +56,7 @@ fn crate_description() { #[test] fn crate_authors() { - let res = App::new("prog") + let res = Command::new("prog") .version("1") .author(crate_authors!()) .try_get_matches_from(vec!["prog", "--help"]); @@ -67,7 +69,7 @@ fn crate_authors() { #[test] fn crate_name() { - let res = App::new(crate_name!()) + let res = Command::new(crate_name!()) .version("3.0") .try_get_matches_from(vec!["clap", "--version"]); diff --git a/tests/builder/conflicts.rs b/tests/builder/conflicts.rs index f59a3bf5c14..f4d07e5c108 100644 --- a/tests/builder/conflicts.rs +++ b/tests/builder/conflicts.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg, ArgGroup}; +use clap::{arg, error::ErrorKind, Arg, ArgGroup, Command}; static CONFLICT_ERR: &str = "error: The argument '--flag' cannot be used with '-F' @@ -30,7 +30,7 @@ For more information try --help #[test] fn flag_conflict() { - let result = App::new("flag_conflict") + let result = Command::new("flag_conflict") .arg(arg!(-f --flag "some flag").conflicts_with("other")) .arg(arg!(-o --other "some flag")) .try_get_matches_from(vec!["myprog", "-f", "-o"]); @@ -41,7 +41,7 @@ fn flag_conflict() { #[test] fn flag_conflict_2() { - let result = App::new("flag_conflict") + let result = Command::new("flag_conflict") .arg(arg!(-f --flag "some flag").conflicts_with("other")) .arg(arg!(-o --other "some flag")) .try_get_matches_from(vec!["myprog", "-o", "-f"]); @@ -52,7 +52,7 @@ fn flag_conflict_2() { #[test] fn flag_conflict_with_all() { - let result = App::new("flag_conflict") + let result = Command::new("flag_conflict") .arg(arg!(-f --flag "some flag").conflicts_with_all(&["other"])) .arg(arg!(-o --other "some flag")) .try_get_matches_from(vec!["myprog", "-o", "-f"]); @@ -63,7 +63,7 @@ fn flag_conflict_with_all() { #[test] fn flag_conflict_with_everything() { - let result = App::new("flag_conflict") + let result = Command::new("flag_conflict") .arg(arg!(-f --flag "some flag").exclusive(true)) .arg(arg!(-o --other "some flag")) .try_get_matches_from(vec!["myprog", "-o", "-f"]); @@ -74,7 +74,7 @@ fn flag_conflict_with_everything() { #[test] fn arg_conflicts_with_group() { - let mut app = App::new("group_conflict") + let mut app = Command::new("group_conflict") .arg(arg!(-f --flag "some flag").conflicts_with("gr")) .group(ArgGroup::new("gr").arg("some").arg("other")) .arg(arg!(--some "some arg")) @@ -108,7 +108,7 @@ fn arg_conflicts_with_group() { #[test] fn arg_conflicts_with_group_with_multiple_sources() { - let mut app = clap::App::new("group_conflict") + let mut app = clap::Command::new("group_conflict") .arg(clap::arg!(-f --flag "some flag").conflicts_with("gr")) .group(clap::ArgGroup::new("gr").multiple(true)) .arg( @@ -145,7 +145,7 @@ fn arg_conflicts_with_group_with_multiple_sources() { #[test] fn group_conflicts_with_arg() { - let mut app = App::new("group_conflict") + let mut app = Command::new("group_conflict") .arg(arg!(-f --flag "some flag")) .group( ArgGroup::new("gr") @@ -184,7 +184,7 @@ fn group_conflicts_with_arg() { #[test] fn arg_conflicts_with_required_group() { - let mut app = App::new("group_conflict") + let mut app = Command::new("group_conflict") .arg(arg!(-f --flag "some flag").conflicts_with("gr")) .group(ArgGroup::new("gr").required(true).arg("some").arg("other")) .arg(arg!(--some "some arg")) @@ -213,7 +213,7 @@ fn arg_conflicts_with_required_group() { #[test] fn required_group_conflicts_with_arg() { - let mut app = App::new("group_conflict") + let mut app = Command::new("group_conflict") .arg(arg!(-f --flag "some flag")) .group( ArgGroup::new("gr") @@ -288,7 +288,7 @@ fn conflict_output_rev_with_required() { #[test] fn conflict_output_three_conflicting() { - let app = App::new("three_conflicting_arguments") + let app = Command::new("three_conflicting_arguments") .arg( Arg::new("one") .long("one") @@ -314,7 +314,7 @@ fn conflict_output_three_conflicting() { #[test] fn two_conflicting_arguments() { - let a = App::new("two_conflicting_arguments") + let a = Command::new("two_conflicting_arguments") .arg( Arg::new("develop") .long("develop") @@ -339,7 +339,7 @@ fn two_conflicting_arguments() { #[test] fn three_conflicting_arguments() { - let a = App::new("three_conflicting_arguments") + let a = Command::new("three_conflicting_arguments") .arg( Arg::new("one") .long("one") @@ -371,7 +371,7 @@ fn three_conflicting_arguments() { #[test] #[should_panic = "Argument 'config' cannot conflict with itself"] fn self_conflicting_arg() { - let _ = App::new("prog") + let _ = Command::new("prog") .arg(Arg::new("config").long("config").conflicts_with("config")) .try_get_matches_from(vec!["", "--config"]); } @@ -380,14 +380,14 @@ fn self_conflicting_arg() { #[test] #[should_panic = "Argument or group 'extra' specified in 'conflicts_with*' for 'config' does not exist"] fn conflicts_with_invalid_arg() { - let _ = App::new("prog") + let _ = Command::new("prog") .arg(Arg::new("config").long("config").conflicts_with("extra")) .try_get_matches_from(vec!["", "--config"]); } #[test] fn conflict_with_unused_default() { - let result = App::new("conflict") + let result = Command::new("conflict") .arg( arg!(-o --opt "some opt") .required(false) @@ -405,7 +405,7 @@ fn conflict_with_unused_default() { #[test] fn conflicts_with_alongside_default() { - let result = App::new("conflict") + let result = Command::new("conflict") .arg( arg!(-o --opt "some opt") .default_value("default") @@ -428,7 +428,7 @@ fn conflicts_with_alongside_default() { #[test] fn group_in_conflicts_with() { - let result = App::new("conflict") + let result = Command::new("conflict") .arg( Arg::new("opt") .long("opt") @@ -451,7 +451,7 @@ fn group_in_conflicts_with() { #[test] fn group_conflicts_with_default_value() { - let result = App::new("conflict") + let result = Command::new("conflict") .arg( Arg::new("opt") .long("opt") @@ -474,7 +474,7 @@ fn group_conflicts_with_default_value() { #[test] fn group_conflicts_with_default_arg() { - let result = App::new("conflict") + let result = Command::new("conflict") .arg(Arg::new("opt").long("opt").default_value("default")) .arg(Arg::new("flag").long("flag").group("one")) .group(ArgGroup::new("one").conflicts_with("opt")) diff --git a/tests/builder/default_missing_vals.rs b/tests/builder/default_missing_vals.rs index 40793043afa..c48f507f5f0 100644 --- a/tests/builder/default_missing_vals.rs +++ b/tests/builder/default_missing_vals.rs @@ -1,8 +1,8 @@ -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command}; #[test] fn opt_missing() { - let r = App::new("df") + let r = Command::new("df") .arg( Arg::new("color") .long("color") @@ -21,7 +21,7 @@ fn opt_missing() { #[test] fn opt_present_with_missing_value() { - let r = App::new("df") + let r = Command::new("df") .arg( Arg::new("color") .long("color") @@ -40,7 +40,7 @@ fn opt_present_with_missing_value() { #[test] fn opt_present_with_value() { - let r = App::new("df") + let r = Command::new("df") .arg( Arg::new("color") .long("color") @@ -59,7 +59,7 @@ fn opt_present_with_value() { #[test] fn opt_present_with_empty_value() { - let r = App::new("df") + let r = Command::new("df") .arg( Arg::new("color") .long("color") @@ -80,7 +80,7 @@ fn opt_present_with_empty_value() { #[test] fn opt_default() { // assert no change to usual argument handling when adding default_missing_value() - let r = App::new("app") + let r = Command::new("app") .arg( arg!(o: -o [opt] "some opt") .default_value("default") @@ -96,7 +96,7 @@ fn opt_default() { #[test] fn opt_default_user_override() { // assert no change to usual argument handling when adding default_missing_value() - let r = App::new("app") + let r = Command::new("app") .arg( arg!(o: -o [opt] "some opt") .default_value("default") @@ -112,7 +112,7 @@ fn opt_default_user_override() { #[test] #[allow(clippy::bool_assert_comparison)] fn default_missing_value_flag_value() { - let app = App::new("test").arg( + let app = Command::new("test").arg( Arg::new("flag") .long("flag") .takes_value(true) @@ -160,9 +160,9 @@ fn default_missing_value_flag_value() { #[test] #[should_panic = "Argument `arg`'s default_missing_value=value doesn't match possible values"] fn default_missing_values_are_possible_values() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg( Arg::new("arg") .possible_values(["one", "two"]) @@ -175,9 +175,9 @@ fn default_missing_values_are_possible_values() { #[test] #[should_panic = "Argument `arg`'s default_missing_value=value failed validation: invalid digit found in string"] fn default_missing_values_are_valid() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg( Arg::new("arg") .validator(|val| val.parse::().map_err(|e| e.to_string())) diff --git a/tests/builder/default_vals.rs b/tests/builder/default_vals.rs index 8c2777a378b..7c93b7a72cc 100644 --- a/tests/builder/default_vals.rs +++ b/tests/builder/default_vals.rs @@ -1,9 +1,9 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg}; +use clap::{arg, error::ErrorKind, Arg, Command}; #[test] fn opts() { - let r = App::new("df") + let r = Command::new("df") .arg( arg!(o: -o "some opt") .required(false) @@ -18,7 +18,7 @@ fn opts() { #[test] fn opt_without_value_fail() { - let r = App::new("df") + let r = Command::new("df") .arg( arg!(o: -o "some opt") .required(false) @@ -36,7 +36,7 @@ fn opt_without_value_fail() { #[test] fn opt_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg( arg!(--opt "some arg") .required(false) @@ -51,7 +51,7 @@ fn opt_user_override() { #[test] fn positionals() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!([arg] "some opt").default_value("default")) .try_get_matches_from(vec![""]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -62,7 +62,7 @@ fn positionals() { #[test] fn positional_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!([arg] "some arg").default_value("default")) .try_get_matches_from(vec!["", "value"]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -78,7 +78,7 @@ fn osstr_opts() { use std::ffi::OsStr; let expected = OsStr::new("default"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!(o: -o "some opt") .required(false) @@ -96,7 +96,7 @@ fn osstr_opt_user_override() { use std::ffi::OsStr; let default = OsStr::new("default"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!(--opt "some arg") .required(false) @@ -114,7 +114,7 @@ fn osstr_positionals() { use std::ffi::OsStr; let expected = OsStr::new("default"); - let r = App::new("df") + let r = Command::new("df") .arg(arg!([arg] "some opt").default_value_os(expected)) .try_get_matches_from(vec![""]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -128,7 +128,7 @@ fn osstr_positional_user_override() { use std::ffi::OsStr; let default = OsStr::new("default"); - let r = App::new("df") + let r = Command::new("df") .arg(arg!([arg] "some arg").default_value_os(default)) .try_get_matches_from(vec!["", "value"]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -141,7 +141,7 @@ fn osstr_positional_user_override() { #[test] fn default_if_arg_present_no_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(true)) .arg(arg!([arg] "some arg").default_value_if("opt", None, Some("default"))) .try_get_matches_from(vec!["", "--opt", "some"]); @@ -153,7 +153,7 @@ fn default_if_arg_present_no_default() { #[test] fn default_if_arg_present_no_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!([arg] "some arg").default_value_if("opt", None, Some("default"))) .try_get_matches_from(vec!["", "--opt", "some", "other"]); @@ -165,7 +165,7 @@ fn default_if_arg_present_no_default_user_override() { #[test] fn default_if_arg_present_no_arg_with_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -181,7 +181,7 @@ fn default_if_arg_present_no_arg_with_default() { #[test] fn default_if_arg_present_with_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -197,7 +197,7 @@ fn default_if_arg_present_with_default() { #[test] fn default_if_arg_present_with_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -213,7 +213,7 @@ fn default_if_arg_present_with_default_user_override() { #[test] fn default_if_arg_present_no_arg_with_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -231,7 +231,7 @@ fn default_if_arg_present_no_arg_with_default_user_override() { #[test] fn default_if_arg_present_with_value_no_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!([arg] "some arg").default_value_if("opt", Some("value"), Some("default"))) .try_get_matches_from(vec!["", "--opt", "value"]); @@ -243,7 +243,7 @@ fn default_if_arg_present_with_value_no_default() { #[test] fn default_if_arg_present_with_value_no_default_fail() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!([arg] "some arg").default_value_if("opt", Some("value"), Some("default"))) .try_get_matches_from(vec!["", "--opt", "other"]); @@ -255,7 +255,7 @@ fn default_if_arg_present_with_value_no_default_fail() { #[test] fn default_if_arg_present_with_value_no_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!([arg] "some arg").default_value_if("opt", Some("some"), Some("default"))) .try_get_matches_from(vec!["", "--opt", "some", "other"]); @@ -267,7 +267,7 @@ fn default_if_arg_present_with_value_no_default_user_override() { #[test] fn default_if_arg_present_with_value_no_arg_with_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -283,7 +283,7 @@ fn default_if_arg_present_with_value_no_arg_with_default() { #[test] fn default_if_arg_present_with_value_no_arg_with_default_fail() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -299,7 +299,7 @@ fn default_if_arg_present_with_value_no_arg_with_default_fail() { #[test] fn default_if_arg_present_with_value_with_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -315,7 +315,7 @@ fn default_if_arg_present_with_value_with_default() { #[test] fn default_if_arg_present_with_value_with_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -331,7 +331,7 @@ fn default_if_arg_present_with_value_with_default_user_override() { #[test] fn default_if_arg_present_no_arg_with_value_with_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -347,7 +347,7 @@ fn default_if_arg_present_no_arg_with_value_with_default_user_override() { #[test] fn default_if_arg_present_no_arg_with_value_with_default_user_override_fail() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -365,7 +365,7 @@ fn default_if_arg_present_no_arg_with_value_with_default_user_override_fail() { #[test] fn no_default_if_arg_present_with_value_no_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!([arg] "some arg").default_value_if("opt", Some("value"), None)) .try_get_matches_from(vec!["", "--opt", "value"]); @@ -376,7 +376,7 @@ fn no_default_if_arg_present_with_value_no_default() { #[test] fn no_default_if_arg_present_with_value_with_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -392,7 +392,7 @@ fn no_default_if_arg_present_with_value_with_default() { #[test] fn no_default_if_arg_present_with_value_with_default_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -408,7 +408,7 @@ fn no_default_if_arg_present_with_value_with_default_user_override() { #[test] fn no_default_if_arg_present_no_arg_with_value_with_default() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg( arg!([arg] "some arg") @@ -426,7 +426,7 @@ fn no_default_if_arg_present_no_arg_with_value_with_default() { #[test] fn default_ifs_arg_present() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!(--flag "some arg")) .arg( @@ -446,7 +446,7 @@ fn default_ifs_arg_present() { #[test] fn no_default_ifs_arg_present() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!(--flag "some arg")) .arg( @@ -463,7 +463,7 @@ fn no_default_ifs_arg_present() { #[test] fn default_ifs_arg_present_user_override() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!(--flag "some arg")) .arg( @@ -483,7 +483,7 @@ fn default_ifs_arg_present_user_override() { #[test] fn default_ifs_arg_present_order() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(--opt "some arg").required(false)) .arg(arg!(--flag "some arg")) .arg( @@ -505,7 +505,7 @@ fn default_ifs_arg_present_order() { #[test] fn conditional_reqs_pass() { - let m = App::new("Test app") + let m = Command::new("Test app") .arg( Arg::new("target") .takes_value(true) @@ -534,7 +534,7 @@ fn conditional_reqs_pass() { #[test] fn multiple_defaults() { - let r = App::new("diff") + let r = Command::new("diff") .arg( Arg::new("files") .long("files") @@ -551,7 +551,7 @@ fn multiple_defaults() { #[test] fn multiple_defaults_override() { - let r = App::new("diff") + let r = Command::new("diff") .arg( Arg::new("files") .long("files") @@ -568,7 +568,7 @@ fn multiple_defaults_override() { #[test] fn default_vals_donnot_show_in_smart_usage() { - let app = App::new("bug") + let app = Command::new("bug") .arg( Arg::new("foo") .long("config") @@ -594,7 +594,7 @@ For more information try --help #[test] fn issue_1050_num_vals_and_defaults() { - let res = App::new("hello") + let res = Command::new("hello") .arg( Arg::new("exit-code") .long("exit-code") @@ -612,9 +612,9 @@ fn issue_1050_num_vals_and_defaults() { #[test] #[should_panic = "Argument group 'group' is required but all of it's arguments have a default value."] fn required_groups_with_default_values() { - use clap::{App, Arg, ArgGroup}; + use clap::{Arg, ArgGroup, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg(Arg::new("arg").default_value("value")) .group(ArgGroup::new("group").args(&["arg"]).required(true)) .try_get_matches(); @@ -624,9 +624,9 @@ fn required_groups_with_default_values() { #[test] #[should_panic = "Argument 'arg' is required and can't have a default value"] fn required_args_with_default_values() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg(Arg::new("arg").required(true).default_value("value")) .try_get_matches(); } @@ -635,9 +635,9 @@ fn required_args_with_default_values() { #[test] #[should_panic = "Argument `arg`'s default_value=value doesn't match possible values"] fn default_values_are_possible_values() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg( Arg::new("arg") .possible_values(["one", "two"]) @@ -650,9 +650,9 @@ fn default_values_are_possible_values() { #[test] #[should_panic = "Argument `arg`'s default_value=value failed validation: invalid digit found in string"] fn default_values_are_valid() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg( Arg::new("arg") .validator(|val| val.parse::().map_err(|e| e.to_string())) @@ -663,7 +663,7 @@ fn default_values_are_valid() { #[test] fn with_value_delimiter() { - let app = App::new("multiple_values").arg( + let app = Command::new("multiple_values").arg( Arg::new("option") .long("option") .help("multiple options") @@ -681,7 +681,7 @@ fn with_value_delimiter() { #[test] fn missing_with_value_delimiter() { - let app = App::new("program").arg( + let app = Command::new("program").arg( Arg::new("option") .long("option") .value_delimiter(';') diff --git a/tests/builder/delimiters.rs b/tests/builder/delimiters.rs index 9b3ec80870a..2ead7a3d333 100644 --- a/tests/builder/delimiters.rs +++ b/tests/builder/delimiters.rs @@ -1,8 +1,8 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; #[test] fn opt_default_no_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg(Arg::new("option").long("option").takes_value(true)) .try_get_matches_from(vec!["", "--option", "val1,val2,val3"]); @@ -16,7 +16,7 @@ fn opt_default_no_delim() { #[test] fn opt_eq_no_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg(Arg::new("option").long("option").takes_value(true)) .try_get_matches_from(vec!["", "--option=val1,val2,val3"]); @@ -30,7 +30,7 @@ fn opt_eq_no_delim() { #[test] fn opt_s_eq_no_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg(Arg::new("option").short('o').takes_value(true)) .try_get_matches_from(vec!["", "-o=val1,val2,val3"]); @@ -44,7 +44,7 @@ fn opt_s_eq_no_delim() { #[test] fn opt_s_default_no_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg(Arg::new("option").short('o').takes_value(true)) .try_get_matches_from(vec!["", "-o", "val1,val2,val3"]); @@ -58,7 +58,7 @@ fn opt_s_default_no_delim() { #[test] fn opt_s_no_space_no_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg(Arg::new("option").short('o').takes_value(true)) .try_get_matches_from(vec!["", "-o", "val1,val2,val3"]); @@ -72,7 +72,7 @@ fn opt_s_no_space_no_delim() { #[test] fn opt_s_no_space_mult_no_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg( Arg::new("option") .short('o') @@ -91,7 +91,7 @@ fn opt_s_no_space_mult_no_delim() { #[test] fn opt_eq_mult_def_delim() { - let m = App::new("no_delim") + let m = Command::new("no_delim") .arg( Arg::new("option") .long("opt") diff --git a/tests/builder/derive_order.rs b/tests/builder/derive_order.rs index f61bbc2cb90..6f6ab41ed0e 100644 --- a/tests/builder/derive_order.rs +++ b/tests/builder/derive_order.rs @@ -2,7 +2,7 @@ use crate::utils; use std::str; -use clap::{App, AppSettings, Arg}; +use clap::{AppSettings, Arg, Command}; static NO_DERIVE_ORDER: &str = "test 1.2 @@ -86,7 +86,7 @@ OPTIONS: #[test] fn no_derive_order() { - let app = App::new("test").version("1.2").args(&[ + let app = Command::new("test").version("1.2").args(&[ Arg::new("flag_b").long("flag_b").help("first flag"), Arg::new("option_b") .long("option_b") @@ -109,7 +109,7 @@ fn no_derive_order() { #[test] fn derive_order() { - let app = App::new("test") + let app = Command::new("test") .setting(AppSettings::DeriveDisplayOrder) .version("1.2") .args(&[ @@ -149,7 +149,7 @@ OPTIONS: --option_a second option "; - let app = App::new("test") + let app = Command::new("test") .setting(AppSettings::DeriveDisplayOrder) .version("1.2") .next_display_order(10000) @@ -188,7 +188,7 @@ OPTIONS: -V, --version Print version information "; - let app = App::new("test") + let app = Command::new("test") .setting(AppSettings::DeriveDisplayOrder) .version("1.2") .next_display_order(None) @@ -212,10 +212,10 @@ OPTIONS: #[test] fn derive_order_subcommand_propagate() { - let app = App::new("test") + let app = Command::new("test") .global_setting(AppSettings::DeriveDisplayOrder) .subcommand( - App::new("sub").version("1.2").args(&[ + Command::new("sub").version("1.2").args(&[ Arg::new("flag_b").long("flag_b").help("first flag"), Arg::new("option_b") .long("option_b") @@ -239,10 +239,10 @@ fn derive_order_subcommand_propagate() { #[test] fn derive_order_subcommand_propagate_with_explicit_display_order() { - let app = App::new("test") + let app = Command::new("test") .global_setting(AppSettings::DeriveDisplayOrder) .subcommand( - App::new("sub").version("1.2").args(&[ + Command::new("sub").version("1.2").args(&[ Arg::new("flag_b").long("flag_b").help("first flag"), Arg::new("option_b") .long("option_b") @@ -269,7 +269,7 @@ fn derive_order_subcommand_propagate_with_explicit_display_order() { #[test] fn prefer_user_help_with_derive_order() { - let app = App::new("test") + let app = Command::new("test") .setting(AppSettings::DeriveDisplayOrder) .version("1.2") .args(&[ @@ -291,10 +291,10 @@ fn prefer_user_help_with_derive_order() { #[test] fn prefer_user_help_in_subcommand_with_derive_order() { - let app = App::new("test") + let app = Command::new("test") .global_setting(AppSettings::DeriveDisplayOrder) .subcommand( - App::new("sub").version("1.2").args(&[ + Command::new("sub").version("1.2").args(&[ Arg::new("help") .long("help") .short('h') diff --git a/tests/builder/display_order.rs b/tests/builder/display_order.rs index cf83fadfca0..ab9c64c8bdd 100644 --- a/tests/builder/display_order.rs +++ b/tests/builder/display_order.rs @@ -1,10 +1,10 @@ use crate::utils; -use clap::App; +use clap::Command; #[test] fn very_large_display_order() { - let app = App::new("test").subcommand(App::new("sub").display_order(usize::MAX)); + let app = Command::new("test").subcommand(Command::new("sub").display_order(usize::MAX)); assert!(utils::compare_output( app, diff --git a/tests/builder/double_require.rs b/tests/builder/double_require.rs index cf29983ccf7..e59e632e147 100644 --- a/tests/builder/double_require.rs +++ b/tests/builder/double_require.rs @@ -1,4 +1,4 @@ -use clap::{error::ErrorKind, App, Arg}; +use clap::{error::ErrorKind, Arg, Command}; static HELP: &str = "prog @@ -30,8 +30,8 @@ USAGE: For more information try --help "; -fn app() -> App<'static> { - App::new("prog") +fn app() -> Command<'static> { + Command::new("prog") .arg( Arg::new("a") .short('a') diff --git a/tests/builder/empty_values.rs b/tests/builder/empty_values.rs index ca22f539f64..b90d30c88d7 100644 --- a/tests/builder/empty_values.rs +++ b/tests/builder/empty_values.rs @@ -1,10 +1,10 @@ use crate::utils; -use clap::{error::ErrorKind, App, Arg}; +use clap::{error::ErrorKind, Arg, Command}; #[test] fn empty_values() { - let m = App::new("config") + let m = Command::new("config") .arg(Arg::new("config").long("config").takes_value(true)) .try_get_matches_from(&["config", "--config", ""]) .unwrap(); @@ -13,13 +13,13 @@ fn empty_values() { #[test] fn empty_values_with_equals() { - let m = App::new("config") + let m = Command::new("config") .arg(Arg::new("config").long("config").takes_value(true)) .try_get_matches_from(&["config", "--config="]) .unwrap(); assert_eq!(m.value_of("config"), Some("")); - let m = App::new("config") + let m = Command::new("config") .arg(Arg::new("config").short('c').takes_value(true)) .try_get_matches_from(&["config", "-c="]) .unwrap(); @@ -28,7 +28,7 @@ fn empty_values_with_equals() { #[test] fn no_empty_values() { - let m = App::new("config") + let m = Command::new("config") .arg( Arg::new("config") .long("config") @@ -39,7 +39,7 @@ fn no_empty_values() { assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::EmptyValue); - let m = App::new("config") + let m = Command::new("config") .arg( Arg::new("config") .short('c') @@ -53,7 +53,7 @@ fn no_empty_values() { #[test] fn no_empty_values_with_equals() { - let m = App::new("config") + let m = Command::new("config") .arg( Arg::new("config") .long("config") @@ -64,7 +64,7 @@ fn no_empty_values_with_equals() { assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::EmptyValue); - let m = App::new("config") + let m = Command::new("config") .arg( Arg::new("config") .short('c') @@ -78,7 +78,7 @@ fn no_empty_values_with_equals() { #[test] fn no_empty_values_without_equals() { - let m = App::new("config") + let m = Command::new("config") .arg( Arg::new("config") .long("config") @@ -89,7 +89,7 @@ fn no_empty_values_without_equals() { assert!(m.is_err()); assert_eq!(m.unwrap_err().kind(), ErrorKind::EmptyValue); - let m = App::new("config") + let m = Command::new("config") .arg( Arg::new("config") .short('c') @@ -103,7 +103,7 @@ fn no_empty_values_without_equals() { #[test] fn no_empty_values_without_equals_but_requires_equals() { - let app = App::new("config").arg( + let app = Command::new("config").arg( Arg::new("config") .long("config") .takes_value(true) diff --git a/tests/builder/env.rs b/tests/builder/env.rs index 115c9cb7da1..e5416eef470 100644 --- a/tests/builder/env.rs +++ b/tests/builder/env.rs @@ -3,13 +3,13 @@ use std::env; use std::ffi::OsStr; -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; #[test] fn env() { env::set_var("CLP_TEST_ENV", "env"); - let r = App::new("df") + let r = Command::new("df") .arg(arg!([arg] "some opt").env("CLP_TEST_ENV").takes_value(true)) .try_get_matches_from(vec![""]); @@ -25,7 +25,7 @@ fn env_bool_literal() { env::set_var("CLP_TEST_FLAG_TRUE", "On"); env::set_var("CLP_TEST_FLAG_FALSE", "nO"); - let r = App::new("df") + let r = Command::new("df") .arg(Arg::new("present").short('p').env("CLP_TEST_FLAG_TRUE")) .arg(Arg::new("negated").short('n').env("CLP_TEST_FLAG_FALSE")) .arg(Arg::new("absent").short('a').env("CLP_TEST_FLAG_ABSENT")) @@ -44,7 +44,7 @@ fn env_bool_literal() { fn env_os() { env::set_var("CLP_TEST_ENV_OS", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env_os(OsStr::new("CLP_TEST_ENV_OS")) @@ -65,7 +65,7 @@ fn no_env() { // we need another variable just in case one of the others is running at the same time... env::remove_var("CLP_TEST_ENV_NONE"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_NONE") @@ -86,7 +86,7 @@ fn no_env_no_takes_value() { // we need another variable just in case one of the others is running at the same time... env::remove_var("CLP_TEST_ENV_NONE"); - let r = App::new("df") + let r = Command::new("df") .arg(arg!([arg] "some opt").env("CLP_TEST_ENV_NONE")) .try_get_matches_from(vec![""]); @@ -101,7 +101,7 @@ fn no_env_no_takes_value() { fn with_default() { env::set_var("CLP_TEST_ENV_WD", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_WD") @@ -121,7 +121,7 @@ fn with_default() { fn opt_user_override() { env::set_var("CLP_TEST_ENV_OR", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!(--arg [FILE] "some arg") .env("CLP_TEST_ENV_OR") @@ -144,7 +144,7 @@ fn opt_user_override() { fn positionals() { env::set_var("CLP_TEST_ENV_P", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_P") @@ -163,7 +163,7 @@ fn positionals() { fn positionals_user_override() { env::set_var("CLP_TEST_ENV_POR", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_POR") @@ -186,7 +186,7 @@ fn positionals_user_override() { fn multiple_one() { env::set_var("CLP_TEST_ENV_MO", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_MO") @@ -207,7 +207,7 @@ fn multiple_one() { fn multiple_three() { env::set_var("CLP_TEST_ENV_MULTI1", "env1,env2,env3"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_MULTI1") @@ -231,7 +231,7 @@ fn multiple_three() { fn multiple_no_delimiter() { env::set_var("CLP_TEST_ENV_MULTI2", "env1 env2 env3"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_MULTI2") @@ -254,7 +254,7 @@ fn multiple_no_delimiter() { fn possible_value() { env::set_var("CLP_TEST_ENV_PV", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_PV") @@ -274,7 +274,7 @@ fn possible_value() { fn not_possible_value() { env::set_var("CLP_TEST_ENV_NPV", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_NPV") @@ -290,7 +290,7 @@ fn not_possible_value() { fn validator() { env::set_var("CLP_TEST_ENV_VDOR", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_VDOR") @@ -316,7 +316,7 @@ fn validator() { fn validator_output() { env::set_var("CLP_TEST_ENV_VO", "42"); - let m = App::new("df") + let m = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_VO") @@ -333,7 +333,7 @@ fn validator_output() { fn validator_invalid() { env::set_var("CLP_TEST_ENV_IV", "env"); - let r = App::new("df") + let r = Command::new("df") .arg( arg!([arg] "some opt") .env("CLP_TEST_ENV_IV") diff --git a/tests/builder/error.rs b/tests/builder/error.rs index f031b51156b..a3e4f4e05ab 100644 --- a/tests/builder/error.rs +++ b/tests/builder/error.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg, Error}; +use clap::{arg, error::ErrorKind, Arg, Command, Error}; fn compare_error( err: Error, @@ -29,7 +29,7 @@ USAGE: For more information try --help "; - let app = App::new("test") + let app = Command::new("test") .arg( Arg::new("all") .short('a') @@ -60,7 +60,7 @@ For more information try --help #[test] fn value_validation_has_newline() { - let m = App::new("test") + let m = Command::new("test") .arg(arg!().help("Network port to use")) .try_get_matches_from(["test", "foo"]) .unwrap(); @@ -78,7 +78,7 @@ fn value_validation_has_newline() { #[test] fn argument_not_found_auto_has_newline() { - let m = App::new("test") + let m = Command::new("test") .arg(arg!([PORT]).help("Network port to use")) .try_get_matches_from(["test"]) .unwrap(); diff --git a/tests/builder/flag_subcommands.rs b/tests/builder/flag_subcommands.rs index fc1b1c2bc95..1fee461e3bd 100644 --- a/tests/builder/flag_subcommands.rs +++ b/tests/builder/flag_subcommands.rs @@ -1,12 +1,12 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg}; +use clap::{arg, error::ErrorKind, Arg, Command}; #[test] fn flag_subcommand_normal() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some").short_flag('S').long_flag("some").arg( + Command::new("some").short_flag('S').long_flag("some").arg( Arg::new("test") .short('t') .long("test") @@ -22,9 +22,9 @@ fn flag_subcommand_normal() { #[test] fn flag_subcommand_normal_with_alias() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .short_flag('S') .long_flag("S") .arg( @@ -44,9 +44,9 @@ fn flag_subcommand_normal_with_alias() { #[test] fn flag_subcommand_short() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some").short_flag('S').arg( + Command::new("some").short_flag('S').arg( Arg::new("test") .short('t') .long("test") @@ -62,9 +62,9 @@ fn flag_subcommand_short() { #[test] fn flag_subcommand_short_with_args() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some").short_flag('S').arg( + Command::new("some").short_flag('S').arg( Arg::new("test") .short('t') .long("test") @@ -80,9 +80,9 @@ fn flag_subcommand_short_with_args() { #[test] fn flag_subcommand_short_with_alias() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .short_flag('S') .arg( Arg::new("test") @@ -102,8 +102,8 @@ fn flag_subcommand_short_with_alias() { #[test] fn flag_subcommand_short_with_alias_same_as_short_flag() { - let matches = App::new("test") - .subcommand(App::new("some").short_flag('S').short_flag_alias('S')) + let matches = Command::new("test") + .subcommand(Command::new("some").short_flag('S').short_flag_alias('S')) .try_get_matches_from(vec!["myprog", "-S"]) .unwrap(); assert_eq!(matches.subcommand_name().unwrap(), "some"); @@ -111,8 +111,12 @@ fn flag_subcommand_short_with_alias_same_as_short_flag() { #[test] fn flag_subcommand_long_with_alias_same_as_long_flag() { - let matches = App::new("test") - .subcommand(App::new("some").long_flag("sync").long_flag_alias("sync")) + let matches = Command::new("test") + .subcommand( + Command::new("some") + .long_flag("sync") + .long_flag_alias("sync"), + ) .try_get_matches_from(vec!["myprog", "--sync"]) .unwrap(); assert_eq!(matches.subcommand_name().unwrap(), "some"); @@ -120,8 +124,8 @@ fn flag_subcommand_long_with_alias_same_as_long_flag() { #[test] fn flag_subcommand_short_with_aliases_vis_and_hidden() { - let app = App::new("test").subcommand( - App::new("some") + let app = Command::new("test").subcommand( + Command::new("some") .short_flag('S') .arg( Arg::new("test") @@ -147,9 +151,9 @@ fn flag_subcommand_short_with_aliases_vis_and_hidden() { #[test] fn flag_subcommand_short_with_aliases() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .short_flag('S') .arg( Arg::new("test") @@ -169,9 +173,9 @@ fn flag_subcommand_short_with_aliases() { #[test] #[should_panic] fn flag_subcommand_short_with_alias_hyphen() { - let _ = App::new("test") + let _ = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .short_flag('S') .arg( Arg::new("test") @@ -188,9 +192,9 @@ fn flag_subcommand_short_with_alias_hyphen() { #[test] #[should_panic] fn flag_subcommand_short_with_aliases_hyphen() { - let _ = App::new("test") + let _ = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .short_flag('S') .arg( Arg::new("test") @@ -206,9 +210,9 @@ fn flag_subcommand_short_with_aliases_hyphen() { #[test] fn flag_subcommand_short_after_long_arg() { - let m = App::new("pacman") + let m = Command::new("pacman") .subcommand( - App::new("sync") + Command::new("sync") .short_flag('S') .arg(Arg::new("clean").short('c')), ) @@ -223,9 +227,9 @@ fn flag_subcommand_short_after_long_arg() { #[test] fn flag_subcommand_long() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some").long_flag("some").arg( + Command::new("some").long_flag("some").arg( Arg::new("test") .short('t') .long("test") @@ -241,9 +245,9 @@ fn flag_subcommand_long() { #[test] fn flag_subcommand_long_with_alias() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .long_flag("some") .arg( Arg::new("test") @@ -262,9 +266,9 @@ fn flag_subcommand_long_with_alias() { #[test] fn flag_subcommand_long_with_aliases() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .long_flag("some") .arg( Arg::new("test") @@ -283,15 +287,15 @@ fn flag_subcommand_long_with_aliases() { #[test] fn flag_subcommand_multiple() { - let matches = App::new("test") + let matches = Command::new("test") .subcommand( - App::new("some") + Command::new("some") .short_flag('S') .long_flag("some") .arg(arg!(-f --flag "some flag")) .arg(arg!(-p --print "print something")) .subcommand( - App::new("result") + Command::new("result") .short_flag('R') .long_flag("result") .arg(arg!(-f --flag "some flag")) @@ -314,8 +318,8 @@ fn flag_subcommand_multiple() { #[test] #[should_panic = "the \'-f\' short flag for the \'test\' argument conflicts with the short flag for \'some\' subcommand"] fn flag_subcommand_short_conflict_with_arg() { - let _ = App::new("test") - .subcommand(App::new("some").short_flag('f').long_flag("some")) + let _ = Command::new("test") + .subcommand(Command::new("some").short_flag('f').long_flag("some")) .arg(Arg::new("test").short('f')) .try_get_matches_from(vec!["myprog", "-f"]) .unwrap(); @@ -325,9 +329,9 @@ fn flag_subcommand_short_conflict_with_arg() { #[test] #[should_panic = "the \'-f\' short flag is specified for both \'some\' and \'result\' subcommands"] fn flag_subcommand_short_conflict_with_alias() { - let _ = App::new("test") - .subcommand(App::new("some").short_flag('f').long_flag("some")) - .subcommand(App::new("result").short_flag('t').short_flag_alias('f')) + let _ = Command::new("test") + .subcommand(Command::new("some").short_flag('f').long_flag("some")) + .subcommand(Command::new("result").short_flag('t').short_flag_alias('f')) .try_get_matches_from(vec!["myprog", "-f"]) .unwrap(); } @@ -336,9 +340,13 @@ fn flag_subcommand_short_conflict_with_alias() { #[test] #[should_panic = "the \'--flag\' long flag is specified for both \'some\' and \'result\' subcommands"] fn flag_subcommand_long_conflict_with_alias() { - let _ = App::new("test") - .subcommand(App::new("some").long_flag("flag")) - .subcommand(App::new("result").long_flag("test").long_flag_alias("flag")) + let _ = Command::new("test") + .subcommand(Command::new("some").long_flag("flag")) + .subcommand( + Command::new("result") + .long_flag("test") + .long_flag_alias("flag"), + ) .try_get_matches_from(vec!["myprog", "--flag"]) .unwrap(); } @@ -347,8 +355,8 @@ fn flag_subcommand_long_conflict_with_alias() { #[test] #[should_panic = "the \'-f\' short flag for the \'test\' argument conflicts with the short flag for \'some\' subcommand"] fn flag_subcommand_short_conflict_with_arg_alias() { - let _ = App::new("test") - .subcommand(App::new("some").short_flag('f').long_flag("some")) + let _ = Command::new("test") + .subcommand(Command::new("some").short_flag('f').long_flag("some")) .arg(Arg::new("test").short('t').short_alias('f')) .try_get_matches_from(vec!["myprog", "-f"]) .unwrap(); @@ -358,8 +366,8 @@ fn flag_subcommand_short_conflict_with_arg_alias() { #[test] #[should_panic = "the \'--some\' long flag for the \'test\' argument conflicts with the short flag for \'some\' subcommand"] fn flag_subcommand_long_conflict_with_arg_alias() { - let _ = App::new("test") - .subcommand(App::new("some").short_flag('f').long_flag("some")) + let _ = Command::new("test") + .subcommand(Command::new("some").short_flag('f').long_flag("some")) .arg(Arg::new("test").long("test").alias("some")) .try_get_matches_from(vec!["myprog", "--some"]) .unwrap(); @@ -369,8 +377,8 @@ fn flag_subcommand_long_conflict_with_arg_alias() { #[test] #[should_panic = "the \'--flag\' long flag for the \'flag\' argument conflicts with the short flag for \'some\' subcommand"] fn flag_subcommand_long_conflict_with_arg() { - let _ = App::new("test") - .subcommand(App::new("some").short_flag('a').long_flag("flag")) + let _ = Command::new("test") + .subcommand(Command::new("some").short_flag('a').long_flag("flag")) .arg(Arg::new("flag").long("flag")) .try_get_matches_from(vec!["myprog", "--flag"]) .unwrap(); @@ -378,25 +386,25 @@ fn flag_subcommand_long_conflict_with_arg() { #[test] fn flag_subcommand_conflict_with_help() { - let _ = App::new("test") - .subcommand(App::new("help").short_flag('h').long_flag("help")) + let _ = Command::new("test") + .subcommand(Command::new("help").short_flag('h').long_flag("help")) .try_get_matches_from(vec!["myprog", "--help"]) .unwrap(); } #[test] fn flag_subcommand_conflict_with_version() { - let _ = App::new("test") - .subcommand(App::new("ver").short_flag('V').long_flag("version")) + let _ = Command::new("test") + .subcommand(Command::new("ver").short_flag('V').long_flag("version")) .try_get_matches_from(vec!["myprog", "--version"]) .unwrap(); } #[test] fn flag_subcommand_long_infer_pass() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test").long_flag("test")) + .subcommand(Command::new("test").long_flag("test")) .try_get_matches_from(vec!["prog", "--te"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("test")); @@ -405,10 +413,10 @@ fn flag_subcommand_long_infer_pass() { #[cfg(not(feature = "suggestions"))] #[test] fn flag_subcommand_long_infer_fail() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test").long_flag("test")) - .subcommand(App::new("temp").long_flag("temp")) + .subcommand(Command::new("test").long_flag("test")) + .subcommand(Command::new("temp").long_flag("temp")) .try_get_matches_from(vec!["prog", "--te"]); assert!(m.is_err(), "{:#?}", m.unwrap()); assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); @@ -417,10 +425,10 @@ fn flag_subcommand_long_infer_fail() { #[cfg(feature = "suggestions")] #[test] fn flag_subcommand_long_infer_fail() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test").long_flag("test")) - .subcommand(App::new("temp").long_flag("temp")) + .subcommand(Command::new("test").long_flag("test")) + .subcommand(Command::new("temp").long_flag("temp")) .try_get_matches_from(vec!["prog", "--te"]); assert!(m.is_err(), "{:#?}", m.unwrap()); assert_eq!(m.unwrap_err().kind(), ErrorKind::UnknownArgument); @@ -428,10 +436,10 @@ fn flag_subcommand_long_infer_fail() { #[test] fn flag_subcommand_long_infer_pass_close() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test").long_flag("test")) - .subcommand(App::new("temp").long_flag("temp")) + .subcommand(Command::new("test").long_flag("test")) + .subcommand(Command::new("temp").long_flag("temp")) .try_get_matches_from(vec!["prog", "--tes"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("test")); @@ -439,11 +447,11 @@ fn flag_subcommand_long_infer_pass_close() { #[test] fn flag_subcommand_long_infer_exact_match() { - let m = App::new("prog") + let m = Command::new("prog") .infer_subcommands(true) - .subcommand(App::new("test").long_flag("test")) - .subcommand(App::new("testa").long_flag("testa")) - .subcommand(App::new("testb").long_flag("testb")) + .subcommand(Command::new("test").long_flag("test")) + .subcommand(Command::new("testa").long_flag("testa")) + .subcommand(Command::new("testb").long_flag("testb")) .try_get_matches_from(vec!["prog", "--test"]) .unwrap(); assert_eq!(m.subcommand_name(), Some("test")); @@ -463,7 +471,7 @@ OPTIONS: #[test] fn flag_subcommand_long_short_normal_usage_string() { - let app = App::new("pacman") + let app = Command::new("pacman") .about("package manager utility") .version("5.2.1") .subcommand_required(true) @@ -472,7 +480,7 @@ fn flag_subcommand_long_short_normal_usage_string() { // // Only a few of its arguments are implemented below. .subcommand( - App::new("query") + Command::new("query") .short_flag('Q') .long_flag("query") .about("Query the package database.") @@ -517,7 +525,7 @@ OPTIONS: #[test] fn flag_subcommand_long_normal_usage_string() { - let app = App::new("pacman") + let app = Command::new("pacman") .about("package manager utility") .version("5.2.1") .subcommand_required(true) @@ -526,7 +534,7 @@ fn flag_subcommand_long_normal_usage_string() { // // Only a few of its arguments are implemented below. .subcommand( - App::new("query") + Command::new("query") .long_flag("query") .about("Query the package database.") .arg( @@ -570,7 +578,7 @@ OPTIONS: #[test] fn flag_subcommand_short_normal_usage_string() { - let app = App::new("pacman") + let app = Command::new("pacman") .about("package manager utility") .version("5.2.1") .subcommand_required(true) @@ -579,7 +587,7 @@ fn flag_subcommand_short_normal_usage_string() { // // Only a few of its arguments are implemented below. .subcommand( - App::new("query") + Command::new("query") .short_flag('Q') .about("Query the package database.") .arg( diff --git a/tests/builder/flags.rs b/tests/builder/flags.rs index 112849374ea..2a244e39541 100644 --- a/tests/builder/flags.rs +++ b/tests/builder/flags.rs @@ -1,5 +1,5 @@ use crate::utils; -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; const USE_FLAG_AS_ARGUMENT: &str = "error: Found argument '--another-flag' which wasn't expected, or isn't valid in this context @@ -14,7 +14,7 @@ For more information try --help #[test] fn flag_using_short() { - let m = App::new("flag") + let m = Command::new("flag") .args(&[ arg!(-f --flag "some flag"), arg!(-c --color "some other flag"), @@ -27,7 +27,7 @@ fn flag_using_short() { #[test] fn lots_o_flags_sep() { - let r = App::new("opts") + let r = Command::new("opts") .arg(arg!(o: -o ... "some flag")) .try_get_matches_from(vec![ "", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", "-o", @@ -61,7 +61,7 @@ fn lots_o_flags_sep() { #[test] fn lots_o_flags_combined() { - let r = App::new("opts") + let r = Command::new("opts") .arg(arg!(o: -o ... "some flag")) .try_get_matches_from(vec![ "", @@ -79,7 +79,7 @@ fn lots_o_flags_combined() { #[test] fn flag_using_long() { - let m = App::new("flag") + let m = Command::new("flag") .args(&[arg!(--flag "some flag"), arg!(--color "some other flag")]) .try_get_matches_from(vec!["", "--flag", "--color"]) .unwrap(); @@ -91,7 +91,7 @@ fn flag_using_long() { fn flag_using_long_with_literals() { use clap::error::ErrorKind; - let m = App::new("flag") + let m = Command::new("flag") .arg(Arg::new("rainbow").long("rainbow")) .try_get_matches_from(vec!["", "--rainbow=false"]); assert!(m.is_err(), "{:#?}", m.unwrap()); @@ -100,7 +100,7 @@ fn flag_using_long_with_literals() { #[test] fn flag_using_mixed() { - let m = App::new("flag") + let m = Command::new("flag") .args(&[ arg!(-f --flag "some flag"), arg!(-c --color "some other flag"), @@ -110,7 +110,7 @@ fn flag_using_mixed() { assert!(m.is_present("flag")); assert!(m.is_present("color")); - let m = App::new("flag") + let m = Command::new("flag") .args(&[ arg!(-f --flag "some flag"), arg!(-c --color "some other flag"), @@ -123,7 +123,7 @@ fn flag_using_mixed() { #[test] fn multiple_flags_in_single() { - let m = App::new("multe_flags") + let m = Command::new("multe_flags") .args(&[ arg!(-f --flag "some flag"), arg!(-c --color "some other flag"), @@ -138,7 +138,7 @@ fn multiple_flags_in_single() { #[test] fn issue_1284_argument_in_flag_style() { - let app = App::new("mycat") + let app = Command::new("mycat") .arg(Arg::new("filename")) .arg(Arg::new("a-flag").long("a-flag")); @@ -180,7 +180,7 @@ USAGE: For more information try --help "; - let app = App::new("test").arg(Arg::new("arg").takes_value(true).required(true)); + let app = Command::new("test").arg(Arg::new("arg").takes_value(true).required(true)); assert!(utils::compare_output( app, diff --git a/tests/builder/global_args.rs b/tests/builder/global_args.rs index c04468d5b80..f1327e874bf 100644 --- a/tests/builder/global_args.rs +++ b/tests/builder/global_args.rs @@ -1,8 +1,8 @@ -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; #[test] fn issue_1076() { - let mut app = App::new("myprog") + let mut app = Command::new("myprog") .arg( Arg::new("GLOBAL_ARG") .long("global-arg") @@ -18,7 +18,7 @@ fn issue_1076() { .global(true) .takes_value(true), ) - .subcommand(App::new("outer").subcommand(App::new("inner"))); + .subcommand(Command::new("outer").subcommand(Command::new("inner"))); let _ = app.try_get_matches_from_mut(vec!["myprog"]); let _ = app.try_get_matches_from_mut(vec!["myprog"]); let _ = app.try_get_matches_from_mut(vec!["myprog"]); @@ -26,11 +26,11 @@ fn issue_1076() { #[test] fn propagate_global_arg_in_subcommand_to_subsubcommand_1385() { - let m1 = App::new("foo") + let m1 = Command::new("foo") .subcommand( - App::new("sub1") + Command::new("sub1") .arg(Arg::new("arg1").long("arg1").takes_value(true).global(true)) - .subcommand(App::new("sub1a")), + .subcommand(Command::new("sub1a")), ) .try_get_matches_from(&["foo", "sub1", "--arg1", "v1", "sub1a"]) .unwrap(); @@ -47,14 +47,14 @@ fn propagate_global_arg_in_subcommand_to_subsubcommand_1385() { #[test] fn propagate_global_arg_to_subcommand_in_subsubcommand_2053() { - let m = App::new("opts") + let m = Command::new("opts") .arg(arg!(--"global-flag").global(true)) .arg(arg!(--"global-str" ).required(false).global(true)) .subcommand( - App::new("test") + Command::new("test") .arg(arg!(--"sub-flag").global(true)) .arg(arg!(--"sub-str" ).required(false).global(true)) - .subcommand(App::new("test")), + .subcommand(Command::new("test")), ) .try_get_matches_from(&[ "app", @@ -76,12 +76,12 @@ fn propagate_global_arg_to_subcommand_in_subsubcommand_2053() { #[test] fn global_arg_available_in_subcommand() { - let m = App::new("opt") + let m = Command::new("opt") .args(&[ Arg::new("global").global(true).long("global"), Arg::new("not").global(false).long("not"), ]) - .subcommand(App::new("ping")) + .subcommand(Command::new("ping")) .try_get_matches_from(&["opt", "ping", "--global"]) .unwrap(); @@ -91,13 +91,17 @@ fn global_arg_available_in_subcommand() { #[test] fn deeply_nested_discovery() { - let app = App::new("a").arg(arg!(--"long-a").global(true)).subcommand( - App::new("b").arg(arg!(--"long-b").global(true)).subcommand( - App::new("c") - .arg(arg!(--"long-c").global(true)) - .subcommand(App::new("d")), - ), - ); + let app = Command::new("a") + .arg(arg!(--"long-a").global(true)) + .subcommand( + Command::new("b") + .arg(arg!(--"long-b").global(true)) + .subcommand( + Command::new("c") + .arg(arg!(--"long-c").global(true)) + .subcommand(Command::new("d")), + ), + ); let m = app .try_get_matches_from(["a", "b", "c", "d", "--long-a", "--long-b", "--long-c"]) diff --git a/tests/builder/grouped_values.rs b/tests/builder/grouped_values.rs index fb88ac37c65..c1e851b2b45 100644 --- a/tests/builder/grouped_values.rs +++ b/tests/builder/grouped_values.rs @@ -1,10 +1,10 @@ #![cfg(feature = "unstable-grouped")] -use clap::{App, Arg}; +use clap::{Arg, Command}; #[test] fn grouped_value_works() { - let m = App::new("cli") + let m = Command::new("cli") .arg( Arg::new("option") .long("option") @@ -34,7 +34,7 @@ fn grouped_value_works() { #[test] fn issue_1026() { - let m = App::new("cli") + let m = Command::new("cli") .arg(Arg::new("server").short('s').takes_value(true)) .arg(Arg::new("user").short('u').takes_value(true)) .arg( @@ -63,7 +63,7 @@ fn issue_1026() { #[test] fn grouped_value_long_flag_delimiter() { - let m = App::new("myapp") + let m = Command::new("myapp") .arg( Arg::new("option") .long("option") @@ -93,7 +93,7 @@ fn grouped_value_long_flag_delimiter() { #[test] fn grouped_value_short_flag_delimiter() { - let m = App::new("myapp") + let m = Command::new("myapp") .arg( Arg::new("option") .short('o') @@ -113,7 +113,7 @@ fn grouped_value_short_flag_delimiter() { #[test] fn grouped_value_positional_arg() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("pos") .help("multiple positionals") @@ -133,7 +133,7 @@ fn grouped_value_positional_arg() { #[test] fn grouped_value_multiple_positional_arg() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos1").help("multiple positionals")) .arg( Arg::new("pos2") @@ -154,7 +154,7 @@ fn grouped_value_multiple_positional_arg() { #[test] fn grouped_value_multiple_positional_arg_last_multiple() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos1").help("multiple positionals")) .arg( Arg::new("pos2") @@ -176,7 +176,7 @@ fn grouped_value_multiple_positional_arg_last_multiple() { #[test] fn issue_1374() { - let app = App::new("MyApp").arg( + let app = Command::new("MyApp").arg( Arg::new("input") .takes_value(true) .long("input") @@ -200,7 +200,7 @@ fn issue_1374() { #[test] fn issue_2171() { - let schema = App::new("ripgrep#1701 reproducer") + let schema = Command::new("ripgrep#1701 reproducer") .args_override_self(true) .arg(Arg::new("pretty").short('p').long("pretty")) .arg(Arg::new("search_zip").short('z').long("search-zip")); diff --git a/tests/builder/groups.rs b/tests/builder/groups.rs index a52549f87de..f8f8445251a 100644 --- a/tests/builder/groups.rs +++ b/tests/builder/groups.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg, ArgGroup}; +use clap::{arg, error::ErrorKind, Arg, ArgGroup, Command}; static REQ_GROUP_USAGE: &str = "error: The following required arguments were not provided: @@ -31,7 +31,7 @@ For more information try --help #[test] fn required_group_missing_arg() { - let result = App::new("group") + let result = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!( -c --color "some other flag")) .group(ArgGroup::new("req").args(&["flag", "color"]).required(true)) @@ -45,7 +45,7 @@ fn required_group_missing_arg() { #[test] #[should_panic = "Argument group 'req' contains non-existent argument"] fn non_existing_arg() { - let _ = App::new("group") + let _ = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color "some other flag")) .group(ArgGroup::new("req").args(&["flg", "color"]).required(true)) @@ -56,7 +56,7 @@ fn non_existing_arg() { #[test] #[should_panic = "Argument group name must be unique\n\n\t'req' is already in use"] fn unique_group_name() { - let _ = App::new("group") + let _ = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color "some other flag")) .group(ArgGroup::new("req").args(&["flag"]).required(true)) @@ -68,7 +68,7 @@ fn unique_group_name() { #[test] #[should_panic = "Argument group name '' must not conflict with argument name"] fn groups_new_of_arg_name() { - let _ = App::new("group") + let _ = Command::new("group") .arg(Arg::new("a").long("a").group("a")) .try_get_matches_from(vec!["", "--a"]); } @@ -77,7 +77,7 @@ fn groups_new_of_arg_name() { #[test] #[should_panic = "Argument group name 'a' must not conflict with argument name"] fn arg_group_new_of_arg_name() { - let _ = App::new("group") + let _ = Command::new("group") .arg(Arg::new("a").long("a").group("a")) .group(ArgGroup::new("a")) .try_get_matches_from(vec!["", "--a"]); @@ -85,7 +85,7 @@ fn arg_group_new_of_arg_name() { #[test] fn group_single_value() { - let res = App::new("group") + let res = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color [color] "some option")) .group(ArgGroup::new("grp").args(&["flag", "color"])) @@ -99,7 +99,7 @@ fn group_single_value() { #[test] fn group_single_flag() { - let res = App::new("group") + let res = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color [color] "some option")) .group(ArgGroup::new("grp").args(&["flag", "color"])) @@ -113,7 +113,7 @@ fn group_single_flag() { #[test] fn group_empty() { - let res = App::new("group") + let res = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color [color] "some option")) .group(ArgGroup::new("grp").args(&["flag", "color"])) @@ -127,7 +127,7 @@ fn group_empty() { #[test] fn group_reqired_flags_empty() { - let result = App::new("group") + let result = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color "some option")) .group(ArgGroup::new("grp").required(true).args(&["flag", "color"])) @@ -139,7 +139,7 @@ fn group_reqired_flags_empty() { #[test] fn group_multi_value_single_arg() { - let res = App::new("group") + let res = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color "some option").multiple_values(true)) .group(ArgGroup::new("grp").args(&["flag", "color"])) @@ -156,7 +156,7 @@ fn group_multi_value_single_arg() { #[test] fn empty_group() { - let r = App::new("empty_group") + let r = Command::new("empty_group") .arg(arg!(-f --flag "some flag")) .group(ArgGroup::new("vers").required(true)) .try_get_matches_from(vec!["empty_prog"]); @@ -167,7 +167,7 @@ fn empty_group() { #[test] fn req_group_usage_string() { - let app = App::new("req_group") + let app = Command::new("req_group") .arg(arg!([base] "Base commit")) .arg(arg!( -d --delete "Remove the base commit information" @@ -188,7 +188,7 @@ fn req_group_usage_string() { #[test] fn req_group_with_conflict_usage_string() { - let app = App::new("req_group") + let app = Command::new("req_group") .arg(arg!([base] "Base commit").conflicts_with("delete")) .arg(arg!( -d --delete "Remove the base commit information" @@ -209,7 +209,7 @@ fn req_group_with_conflict_usage_string() { #[test] fn req_group_with_conflict_usage_string_only_options() { - let app = App::new("req_group") + let app = Command::new("req_group") .arg(arg!(-a --all "All").conflicts_with("delete")) .arg(arg!( -d --delete "Remove the base commit information" @@ -229,7 +229,7 @@ fn req_group_with_conflict_usage_string_only_options() { #[test] fn required_group_multiple_args() { - let result = App::new("group") + let result = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color "some other flag")) .group( @@ -247,7 +247,7 @@ fn required_group_multiple_args() { #[test] fn group_multiple_args_error() { - let result = App::new("group") + let result = Command::new("group") .arg(arg!(-f --flag "some flag")) .arg(arg!(-c --color "some other flag")) .group(ArgGroup::new("req").args(&["flag", "color"])) @@ -270,7 +270,7 @@ ARGS: OPTIONS: -h, --help Print help information "; - let app = App::new("prog") + let app = Command::new("prog") .arg(Arg::new("a").value_name("A")) .group(ArgGroup::new("group").arg("a").required(true)); assert!(utils::compare_output( @@ -283,7 +283,7 @@ OPTIONS: #[test] fn group_acts_like_arg() { - let result = App::new("prog") + let result = Command::new("prog") .arg(Arg::new("debug").long("debug").group("mode")) .arg(Arg::new("verbose").long("verbose").group("mode")) .try_get_matches_from(vec!["prog", "--debug"]); @@ -296,7 +296,7 @@ fn group_acts_like_arg() { /* This is used to be fixed in a hack, we need to find a better way to fix it. #[test] fn issue_1794() { - let app = clap::App::new("hello") + let app = clap::Command::new("hello") .bin_name("deno") .arg(Arg::new("option1").long("option1").takes_value(false)) .arg(Arg::new("pos1").takes_value(true)) diff --git a/tests/builder/help.rs b/tests/builder/help.rs index 4c41af6ce89..cfdfd6d73b1 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg, ArgGroup, PossibleValue}; +use clap::{arg, error::ErrorKind, Arg, ArgGroup, Command, PossibleValue}; static REQUIRE_DELIM_HELP: &str = "test 1.3 Kevin K. @@ -606,8 +606,8 @@ SUBCOMMANDS: sub short about sub "; -fn setup() -> App<'static> { - App::new("test") +fn setup() -> Command<'static> { + Command::new("test") .author("Kevin K.") .about("tests stuff") .version("1.3") @@ -645,7 +645,7 @@ fn help_no_subcommand() { fn help_subcommand() { let m = setup() .subcommand( - App::new("test") + Command::new("test") .about("tests things") .arg(arg!(-v --verbose "with verbosity")), ) @@ -657,7 +657,7 @@ fn help_subcommand() { #[test] fn req_last_arg_usage() { - let app = App::new("example") + let app = Command::new("example") .version("1.0") .arg( Arg::new("FIRST") @@ -682,7 +682,7 @@ fn req_last_arg_usage() { #[test] fn args_with_last_usage() { - let app = App::new("flamegraph") + let app = Command::new("flamegraph") .version("0.1") .trailing_var_arg(true) .arg( @@ -763,7 +763,7 @@ fn complex_help_output() { #[test] fn after_and_before_help_output() { - let app = App::new("clap-test") + let app = Command::new("clap-test") .version("v1.4.8") .about("tests clap library") .before_help("some text that comes before the help") @@ -784,7 +784,7 @@ fn after_and_before_help_output() { #[test] fn after_and_before_long_help_output() { - let app = App::new("clap-test") + let app = Command::new("clap-test") .version("v1.4.8") .about("tests clap library") .before_help("some text that comes before the help") @@ -807,9 +807,9 @@ fn after_and_before_long_help_output() { #[test] fn multi_level_sc_help() { - let app = App::new("ctest").subcommand( - App::new("subcmd").subcommand( - App::new("multi") + let app = Command::new("ctest").subcommand( + Command::new("subcmd").subcommand( + Command::new("multi") .about("tests subcommands") .author("Kevin K. ") .version("0.1") @@ -836,7 +836,9 @@ fn multi_level_sc_help() { #[test] fn no_wrap_help() { - let app = App::new("ctest").term_width(0).override_help(MULTI_SC_HELP); + let app = Command::new("ctest") + .term_width(0) + .override_help(MULTI_SC_HELP); assert!(utils::compare_output( app, "ctest --help", @@ -847,7 +849,7 @@ fn no_wrap_help() { #[test] fn no_wrap_default_help() { - let app = App::new("ctest").version("1.0").term_width(0); + let app = Command::new("ctest").version("1.0").term_width(0); assert!(utils::compare_output( app, "ctest --help", @@ -882,7 +884,7 @@ OPTIONS: --no-git-push Do not push generated commit and tags to git remote "; - let app = App::new("test") + let app = Command::new("test") .term_width(67) .arg( Arg::new("all") @@ -931,7 +933,7 @@ OPTIONS: --no-git-push Do not push generated commit and tags to git remote "; - let app = App::new("test") + let app = Command::new("test") .term_width(68) .arg( Arg::new("all") @@ -975,7 +977,7 @@ fn complex_subcommand_help_output() { #[test] fn issue_626_unicode_cutoff() { - let app = App::new("ctest").version("0.1").term_width(70).arg( + let app = Command::new("ctest").version("0.1").term_width(70).arg( Arg::new("cafe") .short('c') .long("cafe") @@ -1000,7 +1002,7 @@ fn issue_626_unicode_cutoff() { #[test] fn hide_possible_vals() { - let app = App::new("ctest") + let app = Command::new("ctest") .version("0.1") .arg( Arg::new("pos") @@ -1031,7 +1033,7 @@ fn hide_possible_vals() { #[test] fn hide_single_possible_val() { - let app = App::new("ctest") + let app = Command::new("ctest") .version("0.1") .arg( Arg::new("pos") @@ -1061,7 +1063,7 @@ fn hide_single_possible_val() { #[test] fn issue_626_panic() { - let app = App::new("ctest") + let app = Command::new("ctest") .version("0.1") .term_width(52) .arg(Arg::new("cafe") @@ -1083,7 +1085,7 @@ fn issue_626_panic() { #[test] fn issue_626_variable_panic() { for i in 10..320 { - let _ = App::new("ctest") + let _ = Command::new("ctest") .version("0.1") .term_width(i) .arg(Arg::new("cafe") @@ -1100,7 +1102,7 @@ fn issue_626_variable_panic() { #[test] fn final_word_wrapping() { - let app = App::new("ctest").version("0.1").term_width(24); + let app = Command::new("ctest").version("0.1").term_width(24); assert!(utils::compare_output( app, "ctest --help", @@ -1111,7 +1113,7 @@ fn final_word_wrapping() { #[test] fn wrapping_newline_chars() { - let app = App::new("ctest") + let app = Command::new("ctest") .version("0.1") .term_width(60) .arg(Arg::new("mode").help( @@ -1129,7 +1131,7 @@ fn wrapping_newline_chars() { #[test] fn wrapping_newline_variables() { - let app = App::new("ctest") + let app = Command::new("ctest") .version("0.1") .term_width(60) .arg(Arg::new("mode").help( @@ -1147,7 +1149,7 @@ fn wrapping_newline_variables() { #[test] fn old_newline_chars() { - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("mode") .short('m') .help("Some help with some wrapping\n(Defaults to something)"), @@ -1162,7 +1164,7 @@ fn old_newline_chars() { #[test] fn old_newline_variables() { - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("mode") .short('m') .help("Some help with some wrapping{n}(Defaults to something)"), @@ -1179,7 +1181,7 @@ fn old_newline_variables() { fn issue_688_hide_pos_vals() { let filter_values = ["Nearest", "Linear", "Cubic", "Gaussian", "Lanczos3"]; - let app1 = App::new("ctest") + let app1 = Command::new("ctest") .version("0.1") .term_width(120) .hide_possible_values(true) @@ -1196,7 +1198,7 @@ fn issue_688_hide_pos_vals() { false )); - let app2 = App::new("ctest") + let app2 = Command::new("ctest") .version("0.1") .term_width(120) .arg(Arg::new("filter") @@ -1212,7 +1214,7 @@ fn issue_688_hide_pos_vals() { false )); - let app3 = App::new("ctest") + let app3 = Command::new("ctest") .version("0.1") .term_width(120) .arg(Arg::new("filter") @@ -1230,7 +1232,7 @@ fn issue_688_hide_pos_vals() { #[test] fn issue_702_multiple_values() { - let app = App::new("myapp") + let app = Command::new("myapp") .version("1.0") .author("foo") .about("bar") @@ -1268,7 +1270,7 @@ fn issue_702_multiple_values() { #[test] fn long_about() { - let app = App::new("myapp") + let app = Command::new("myapp") .version("1.0") .author("foo") .about("bar") @@ -1286,7 +1288,7 @@ fn long_about() { #[test] fn issue_760() { - let app = App::new("ctest") + let app = Command::new("ctest") .version("0.1") .arg( Arg::new("option") @@ -1309,7 +1311,7 @@ fn issue_760() { #[test] fn issue_1571() { - let app = App::new("hello").arg( + let app = Command::new("hello").arg( Arg::new("name") .long("package") .short('p') @@ -1335,7 +1337,7 @@ OPTIONS: #[test] fn ripgrep_usage() { - let app = App::new("ripgrep").version("0.5").override_usage( + let app = Command::new("ripgrep").version("0.5").override_usage( "rg [OPTIONS] [ ...] rg [OPTIONS] [-e PATTERN | -f FILE ]... [ ...] rg [OPTIONS] --files [ ...] @@ -1352,7 +1354,7 @@ fn ripgrep_usage() { #[test] fn ripgrep_usage_using_templates() { - let app = App::new("ripgrep") + let app = Command::new("ripgrep") .version("0.5") .override_usage( " @@ -1381,12 +1383,12 @@ OPTIONS: #[test] fn sc_negates_reqs() { - let app = App::new("prog") + let app = Command::new("prog") .version("1.0") .subcommand_negates_reqs(true) .arg(arg!(-o --opt "tests options")) .arg(Arg::new("PATH").help("help")) - .subcommand(App::new("test")); + .subcommand(Command::new("test")); assert!(utils::compare_output( app, "prog --help", @@ -1397,7 +1399,7 @@ fn sc_negates_reqs() { #[test] fn hide_args() { - let app = App::new("prog") + let app = Command::new("prog") .version("1.0") .arg(arg!(-f --flag "testing flags")) .arg(arg!(-o --opt "tests options").required(false)) @@ -1412,13 +1414,13 @@ fn hide_args() { #[test] fn args_negate_sc() { - let app = App::new("prog") + let app = Command::new("prog") .version("1.0") .args_conflicts_with_subcommands(true) .arg(arg!(-f --flag "testing flags")) .arg(arg!(-o --opt "tests options").required(false)) .arg(Arg::new("PATH").help("help")) - .subcommand(App::new("test")); + .subcommand(Command::new("test")); assert!(utils::compare_output( app, "prog --help", @@ -1429,12 +1431,12 @@ fn args_negate_sc() { #[test] fn issue_1046_hide_scs() { - let app = App::new("prog") + let app = Command::new("prog") .version("1.0") .arg(arg!(-f --flag "testing flags")) .arg(arg!(-o --opt "tests options").required(false)) .arg(Arg::new("PATH").help("some")) - .subcommand(App::new("test").hide(true)); + .subcommand(Command::new("test").hide(true)); assert!(utils::compare_output( app, "prog --help", @@ -1445,7 +1447,7 @@ fn issue_1046_hide_scs() { #[test] fn issue_777_wrap_all_things() { - let app = App::new("A app with a crazy very long long long name hahaha") + let app = Command::new("A app with a crazy very long long long name hahaha") .version("1.0") .author("Some Very Long Name and crazy long email ") .about("Show how the about text is not wrapped") @@ -1465,7 +1467,7 @@ OPTIONS: #[test] fn override_help_short() { - let app = App::new("test") + let app = Command::new("test") .version("0.1") .mut_arg("help", |h| h.short('H')); @@ -1495,7 +1497,7 @@ OPTIONS: #[test] fn override_help_long() { - let app = App::new("test") + let app = Command::new("test") .version("0.1") .mut_arg("help", |h| h.long("hell")); @@ -1525,7 +1527,7 @@ OPTIONS: #[test] fn override_help_about() { - let app = App::new("test") + let app = Command::new("test") .version("0.1") .mut_arg("help", |h| h.help("Print help information")); @@ -1545,7 +1547,7 @@ fn override_help_about() { #[test] fn arg_short_conflict_with_help() { - let app = App::new("conflict").arg(Arg::new("home").short('h')); + let app = Command::new("conflict").arg(Arg::new("home").short('h')); assert!(utils::compare_output( app, @@ -1559,7 +1561,7 @@ fn arg_short_conflict_with_help() { #[test] #[should_panic = "`help`s `-h` conflicts with `home`."] fn arg_short_conflict_with_help_mut_arg() { - let _ = App::new("conflict") + let _ = Command::new("conflict") .arg(Arg::new("home").short('h')) .mut_arg("help", |h| h.short('h')) .try_get_matches_from(vec![""]); @@ -1567,7 +1569,7 @@ fn arg_short_conflict_with_help_mut_arg() { #[test] fn last_arg_mult_usage() { - let app = App::new("last") + let app = Command::new("last") .version("0.1") .arg(Arg::new("TARGET").required(true).help("some")) .arg(Arg::new("CORPUS").help("some")) @@ -1583,7 +1585,7 @@ fn last_arg_mult_usage() { #[test] fn last_arg_mult_usage_req() { - let app = App::new("last") + let app = Command::new("last") .version("0.1") .arg(Arg::new("TARGET").required(true).help("some")) .arg(Arg::new("CORPUS").help("some")) @@ -1605,7 +1607,7 @@ fn last_arg_mult_usage_req() { #[test] fn last_arg_mult_usage_req_with_sc() { - let app = App::new("last") + let app = Command::new("last") .version("0.1") .subcommand_negates_reqs(true) .arg(Arg::new("TARGET").required(true).help("some")) @@ -1618,7 +1620,7 @@ fn last_arg_mult_usage_req_with_sc() { .required(true) .help("some"), ) - .subcommand(App::new("test").about("some")); + .subcommand(Command::new("test").about("some")); assert!(utils::compare_output( app, "last --help", @@ -1629,7 +1631,7 @@ fn last_arg_mult_usage_req_with_sc() { #[test] fn last_arg_mult_usage_with_sc() { - let app = App::new("last") + let app = Command::new("last") .version("0.1") .args_conflicts_with_subcommands(true) .arg(Arg::new("TARGET").required(true).help("some")) @@ -1641,7 +1643,7 @@ fn last_arg_mult_usage_with_sc() { .last(true) .help("some"), ) - .subcommand(App::new("test").about("some")); + .subcommand(Command::new("test").about("some")); assert!(utils::compare_output( app, "last --help", @@ -1652,7 +1654,7 @@ fn last_arg_mult_usage_with_sc() { #[test] fn hide_default_val() { - let app1 = App::new("default").version("0.1").term_width(120).arg( + let app1 = Command::new("default").version("0.1").term_width(120).arg( Arg::new("argument") .help("Pass an argument to the program. [default: default-argument]") .long("arg") @@ -1666,7 +1668,7 @@ fn hide_default_val() { false )); - let app2 = App::new("default").version("0.1").term_width(120).arg( + let app2 = Command::new("default").version("0.1").term_width(120).arg( Arg::new("argument") .help("Pass an argument to the program.") .long("arg") @@ -1682,7 +1684,7 @@ fn hide_default_val() { #[test] fn escaped_whitespace_values() { - let app1 = App::new("default").version("0.1").term_width(120).arg( + let app1 = Command::new("default").version("0.1").term_width(120).arg( Arg::new("argument") .help("Pass an argument to the program.") .long("arg") @@ -1697,12 +1699,12 @@ fn escaped_whitespace_values() { )); } -fn issue_1112_setup() -> App<'static> { - App::new("test") +fn issue_1112_setup() -> Command<'static> { + Command::new("test") .version("1.3") .arg(Arg::new("help1").long("help").short('h').help("some help")) .subcommand( - App::new("foo").arg(Arg::new("help1").long("help").short('h').help("some help")), + Command::new("foo").arg(Arg::new("help1").long("help").short('h').help("some help")), ) } @@ -1748,7 +1750,7 @@ fn prefer_user_subcmd_help_short_1112() { #[test] fn issue_1052_require_delim_help() { - let app = App::new("test") + let app = Command::new("test") .author("Kevin K.") .about("tests stuff") .version("1.3") @@ -1772,7 +1774,7 @@ fn issue_1052_require_delim_help() { #[test] fn custom_headers_headers() { - let app = App::new("blorp") + let app = Command::new("blorp") .author("Will M.") .about("does stuff") .version("1.4") @@ -1829,7 +1831,7 @@ SPECIAL: #[test] fn multiple_custom_help_headers() { - let app = App::new("blorp") + let app = Command::new("blorp") .author("Will M.") .about("does stuff") .version("1.4") @@ -1908,7 +1910,7 @@ SPECIAL: #[test] fn custom_help_headers_hide_args() { - let app = App::new("blorp") + let app = Command::new("blorp") .author("Will M.") .about("does stuff") .version("1.4") @@ -1962,8 +1964,8 @@ OPTIONS: #[test] fn show_long_about_issue_897() { - let app = App::new("ctest").version("0.1").subcommand( - App::new("foo") + let app = Command::new("ctest").version("0.1").subcommand( + Command::new("foo") .version("0.1") .about("About foo") .long_about("Long about foo"), @@ -1989,8 +1991,8 @@ OPTIONS: #[test] fn show_short_about_issue_897() { - let app = App::new("ctest").version("0.1").subcommand( - App::new("foo") + let app = Command::new("ctest").version("0.1").subcommand( + Command::new("foo") .version("0.1") .about("About foo") .long_about("Long about foo"), @@ -2005,7 +2007,7 @@ fn show_short_about_issue_897() { #[test] fn issue_1364_no_short_options() { - let app = App::new("demo") + let app = Command::new("demo") .arg(Arg::new("foo").short('f')) .arg( Arg::new("baz") @@ -2026,7 +2028,7 @@ fn issue_1364_no_short_options() { #[rustfmt::skip] #[test] fn issue_1487() { - let app = App::new("test") + let app = Command::new("test") .arg(Arg::new("arg1") .group("group1")) .arg(Arg::new("arg2") @@ -2039,9 +2041,9 @@ fn issue_1487() { #[cfg(debug_assertions)] #[test] -#[should_panic = "AppSettings::HelpExpected is enabled for the App"] +#[should_panic = "AppSettings::HelpExpected is enabled for the Command"] fn help_required_but_not_given() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .arg(Arg::new("foo")) .try_get_matches_from(empty_args()) @@ -2050,9 +2052,9 @@ fn help_required_but_not_given() { #[cfg(debug_assertions)] #[test] -#[should_panic = "AppSettings::HelpExpected is enabled for the App"] +#[should_panic = "AppSettings::HelpExpected is enabled for the Command"] fn help_required_but_not_given_settings_after_args() { - App::new("myapp") + Command::new("myapp") .arg(Arg::new("foo")) .help_expected(true) .try_get_matches_from(empty_args()) @@ -2061,9 +2063,9 @@ fn help_required_but_not_given_settings_after_args() { #[cfg(debug_assertions)] #[test] -#[should_panic = "AppSettings::HelpExpected is enabled for the App"] +#[should_panic = "AppSettings::HelpExpected is enabled for the Command"] fn help_required_but_not_given_for_one_of_two_arguments() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .arg(Arg::new("foo")) .arg(Arg::new("bar").help("It does bar stuff")) @@ -2074,11 +2076,11 @@ fn help_required_but_not_given_for_one_of_two_arguments() { #[test] #[should_panic = "List of such arguments: delete"] fn help_required_globally() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .arg(Arg::new("foo").help("It does foo stuff")) .subcommand( - App::new("bar") + Command::new("bar") .arg(Arg::new("create").help("creates bar")) .arg(Arg::new("delete")), ) @@ -2088,13 +2090,13 @@ fn help_required_globally() { #[cfg(debug_assertions)] #[test] -#[should_panic = "AppSettings::HelpExpected is enabled for the App"] +#[should_panic = "AppSettings::HelpExpected is enabled for the Command"] fn help_required_globally_but_not_given_for_subcommand() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .arg(Arg::new("foo").help("It does foo stuff")) .subcommand( - App::new("bar") + Command::new("bar") .arg(Arg::new("create").help("creates bar")) .arg(Arg::new("delete")), ) @@ -2104,11 +2106,11 @@ fn help_required_globally_but_not_given_for_subcommand() { #[test] fn help_required_and_given_for_subcommand() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .arg(Arg::new("foo").help("It does foo stuff")) .subcommand( - App::new("bar") + Command::new("bar") .arg(Arg::new("create").help("creates bar")) .arg(Arg::new("delete").help("deletes bar")), ) @@ -2118,7 +2120,7 @@ fn help_required_and_given_for_subcommand() { #[test] fn help_required_and_given() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .arg(Arg::new("foo").help("It does foo stuff")) .try_get_matches_from(empty_args()) @@ -2127,7 +2129,7 @@ fn help_required_and_given() { #[test] fn help_required_and_no_args() { - App::new("myapp") + Command::new("myapp") .help_expected(true) .try_get_matches_from(empty_args()) .unwrap(); @@ -2135,7 +2137,7 @@ fn help_required_and_no_args() { #[test] fn issue_1642_long_help_spacing() { - let app = App::new("prog").arg(Arg::new("cfg").long("config").long_help( + let app = Command::new("prog").arg(Arg::new("cfg").long("config").long_help( "The config file used by the myprog must be in JSON format with only valid keys and may not contain other nonsense that cannot be read by this program. Obviously I'm going on @@ -2154,7 +2156,7 @@ This is after help. #[test] fn after_help_no_args() { - let mut app = App::new("myapp") + let mut app = Command::new("myapp") .version("1.0") .disable_help_flag(true) .disable_version_flag(true) @@ -2184,9 +2186,9 @@ OPTIONS: #[test] fn help_subcmd_help() { - let app = App::new("myapp") + let app = Command::new("myapp") .mut_arg("help", |h| h.help("Print custom help text")) - .subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0"))); + .subcommand(Command::new("subcmd").subcommand(Command::new("multi").version("1.0"))); assert!(utils::compare_output( app.clone(), @@ -2211,9 +2213,9 @@ OPTIONS: #[test] fn subcmd_help_subcmd_help() { - let app = App::new("myapp") + let app = Command::new("myapp") .mut_arg("help", |h| h.help("Print custom help text")) - .subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0"))); + .subcommand(Command::new("subcmd").subcommand(Command::new("multi").version("1.0"))); assert!(utils::compare_output( app.clone(), @@ -2245,9 +2247,9 @@ OPTIONS: #[test] fn help_about_multi_subcmd() { - let app = App::new("myapp") + let app = Command::new("myapp") .mut_arg("help", |h| h.help("Print custom help text")) - .subcommand(App::new("subcmd").subcommand(App::new("multi").version("1.0"))); + .subcommand(Command::new("subcmd").subcommand(Command::new("multi").version("1.0"))); assert!(utils::compare_output( app.clone(), @@ -2271,11 +2273,11 @@ fn help_about_multi_subcmd() { #[test] fn help_about_multi_subcmd_override() { - let app = App::new("myapp") + let app = Command::new("myapp") .mut_arg("help", |h| h.help("Print custom help text")) .subcommand( - App::new("subcmd").subcommand( - App::new("multi") + Command::new("subcmd").subcommand( + Command::new("multi") .version("1.0") .mut_arg("help", |h| h.help("Print custom help text from multi")), ), @@ -2303,7 +2305,7 @@ fn help_about_multi_subcmd_override() { #[test] fn option_usage_order() { - let app = App::new("order").args(&[ + let app = Command::new("order").args(&[ Arg::new("a").short('a'), Arg::new("B").short('B'), Arg::new("b").short('b'), @@ -2323,8 +2325,8 @@ fn option_usage_order() { #[test] fn prefer_about_over_long_about_in_subcommands_list() { - let app = App::new("about-in-subcommands-list").subcommand( - App::new("sub") + let app = Command::new("about-in-subcommands-list").subcommand( + Command::new("sub") .long_about("long about sub") .about("short about sub"), ); @@ -2353,7 +2355,7 @@ OPTIONS: --option1 "; - let app = clap::App::new("hello") + let app = clap::Command::new("hello") .bin_name("deno") .arg(Arg::new("option1").long("option1").takes_value(false)) .arg(Arg::new("pos1").takes_value(true)) @@ -2390,7 +2392,7 @@ NETWORKING: #[test] fn custom_heading_pos() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") .arg(Arg::new("gear").help("Which gear")) .next_help_heading(Some("NETWORKING")) @@ -2415,7 +2417,7 @@ NETWORKING: #[test] fn only_custom_heading_opts_no_args() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") .disable_version_flag(true) .mut_arg("help", |a| a.hide(true)) @@ -2441,7 +2443,7 @@ NETWORKING: #[test] fn only_custom_heading_pos_no_args() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") .disable_version_flag(true) .mut_arg("help", |a| a.hide(true)) @@ -2458,7 +2460,7 @@ fn only_custom_heading_pos_no_args() { #[test] fn issue_2508_number_of_values_with_single_value_name() { - let app = App::new("my_app") + let app = Command::new("my_app") .arg(Arg::new("some_arg").long("some_arg").number_of_values(2)) .arg( Arg::new("some_arg_issue") @@ -2485,7 +2487,7 @@ OPTIONS: #[test] fn missing_positional_final_required() { - let app = App::new("test") + let app = Command::new("test") .allow_missing_positional(true) .arg(Arg::new("arg1")) .arg(Arg::new("arg2").required(true)); @@ -2510,7 +2512,7 @@ OPTIONS: #[test] fn missing_positional_final_multiple() { - let app = App::new("test") + let app = Command::new("test") .allow_missing_positional(true) .arg(Arg::new("foo")) .arg(Arg::new("bar")) @@ -2537,7 +2539,7 @@ OPTIONS: #[test] fn positional_multiple_values_is_dotted() { - let app = App::new("test").arg( + let app = Command::new("test").arg( Arg::new("foo") .required(true) .takes_value(true) @@ -2560,7 +2562,7 @@ OPTIONS: false )); - let app = App::new("test").arg( + let app = Command::new("test").arg( Arg::new("foo") .required(true) .takes_value(true) @@ -2587,7 +2589,7 @@ OPTIONS: #[test] fn positional_multiple_occurrences_is_dotted() { - let app = App::new("test").arg( + let app = Command::new("test").arg( Arg::new("foo") .required(true) .takes_value(true) @@ -2610,7 +2612,7 @@ OPTIONS: false )); - let app = App::new("test").arg( + let app = Command::new("test").arg( Arg::new("foo") .required(true) .takes_value(true) @@ -2637,8 +2639,8 @@ OPTIONS: #[test] fn disabled_help_flag() { - let res = App::new("foo") - .subcommand(App::new("sub")) + let res = Command::new("foo") + .subcommand(Command::new("sub")) .disable_help_flag(true) .try_get_matches_from("foo a".split(' ')); assert!(res.is_err()); @@ -2648,8 +2650,8 @@ fn disabled_help_flag() { #[test] fn disabled_help_flag_and_subcommand() { - let res = App::new("foo") - .subcommand(App::new("sub")) + let res = Command::new("foo") + .subcommand(Command::new("sub")) .disable_help_flag(true) .disable_help_subcommand(true) .try_get_matches_from("foo help".split(' ')); @@ -2665,9 +2667,9 @@ fn disabled_help_flag_and_subcommand() { #[test] fn override_help_subcommand() { - let app = App::new("bar") - .subcommand(App::new("help").arg(Arg::new("arg").takes_value(true))) - .subcommand(App::new("not_help").arg(Arg::new("arg").takes_value(true))) + let app = Command::new("bar") + .subcommand(Command::new("help").arg(Arg::new("arg").takes_value(true))) + .subcommand(Command::new("not_help").arg(Arg::new("arg").takes_value(true))) .disable_help_subcommand(true); let matches = app.try_get_matches_from(&["bar", "help", "foo"]).unwrap(); assert_eq!( @@ -2678,8 +2680,8 @@ fn override_help_subcommand() { #[test] fn override_help_flag_using_long() { - let app = App::new("foo") - .subcommand(App::new("help").long_flag("help")) + let app = Command::new("foo") + .subcommand(Command::new("help").long_flag("help")) .disable_help_flag(true); let matches = app.try_get_matches_from(&["foo", "--help"]).unwrap(); assert!(matches.subcommand_matches("help").is_some()); @@ -2687,9 +2689,9 @@ fn override_help_flag_using_long() { #[test] fn override_help_flag_using_short() { - let app = App::new("foo") + let app = Command::new("foo") .disable_help_flag(true) - .subcommand(App::new("help").short_flag('h')); + .subcommand(Command::new("help").short_flag('h')); let matches = app.try_get_matches_from(&["foo", "-h"]).unwrap(); assert!(matches.subcommand_matches("help").is_some()); } @@ -2698,7 +2700,7 @@ fn override_help_flag_using_short() { fn subcommand_help_doesnt_have_useless_help_flag() { // The main care-about is that the docs and behavior match. Since the `help` subcommand // currently ignores the `--help` flag, the output shouldn't have it. - let app = App::new("test_app").subcommand(App::new("test").about("Subcommand")); + let app = Command::new("test_app").subcommand(Command::new("test").about("Subcommand")); assert!(utils::compare_output( app, @@ -2718,9 +2720,9 @@ ARGS: #[test] fn disable_help_flag_affects_help_subcommand() { - let mut app = App::new("test_app") + let mut app = Command::new("test_app") .disable_help_flag(true) - .subcommand(App::new("test").about("Subcommand")); + .subcommand(Command::new("test").about("Subcommand")); app._build_all(); let args = app @@ -2738,10 +2740,10 @@ fn disable_help_flag_affects_help_subcommand() { #[test] fn dont_propagate_version_to_help_subcommand() { - let app = clap::App::new("test") + let app = clap::Command::new("test") .version("1.0") .propagate_version(true) - .subcommand(clap::App::new("subcommand")); + .subcommand(clap::Command::new("subcommand")); assert!(utils::compare_output( app.clone(), @@ -2763,7 +2765,7 @@ ARGS: #[test] fn help_without_short() { - let mut app = clap::App::new("test") + let mut app = clap::Command::new("test") .arg(arg!(-h --hex )) .arg(arg!(--help)); diff --git a/tests/builder/help_env.rs b/tests/builder/help_env.rs index d203ed1518a..4e54db8b3fa 100644 --- a/tests/builder/help_env.rs +++ b/tests/builder/help_env.rs @@ -2,7 +2,7 @@ use std::env; -use clap::{App, Arg}; +use clap::{Arg, Command}; use crate::utils; @@ -98,7 +98,7 @@ OPTIONS: fn hide_env() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -116,7 +116,7 @@ fn hide_env() { fn show_env() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -133,7 +133,7 @@ fn show_env() { fn hide_env_vals() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -156,7 +156,7 @@ fn hide_env_vals() { fn show_env_vals() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -178,7 +178,7 @@ fn show_env_vals() { fn hide_env_flag() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -199,7 +199,7 @@ fn hide_env_flag() { fn show_env_flag() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -219,7 +219,7 @@ fn show_env_flag() { fn hide_env_vals_flag() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") @@ -240,7 +240,7 @@ fn hide_env_vals_flag() { fn show_env_vals_flag() { env::set_var("ENVVAR", "MYVAL"); - let app = App::new("ctest").version("0.1").arg( + let app = Command::new("ctest").version("0.1").arg( Arg::new("cafe") .short('c') .long("cafe") diff --git a/tests/builder/hidden_args.rs b/tests/builder/hidden_args.rs index 7ae82e2a4d1..b2fb4ae75bb 100644 --- a/tests/builder/hidden_args.rs +++ b/tests/builder/hidden_args.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; static HIDDEN_ARGS: &str = "test 1.4 Kevin K. @@ -18,7 +18,7 @@ OPTIONS: #[test] fn hide_args() { - let app = App::new("test") + let app = Command::new("test") .author("Kevin K.") .about("tests stuff") .version("1.4") @@ -73,7 +73,7 @@ OPTIONS: /// Ensure hide with short option #[test] fn hide_short_args() { - let app = App::new("test") + let app = Command::new("test") .about("hides short args") .author("Steve P.") .version("2.31.2") @@ -100,7 +100,7 @@ fn hide_short_args() { /// Ensure visible with opposite option #[test] fn hide_short_args_long_help() { - let app = App::new("test") + let app = Command::new("test") .about("hides short args") .author("Steve P.") .version("2.31.2") @@ -144,7 +144,7 @@ OPTIONS: #[test] fn hide_long_args() { - let app = App::new("test") + let app = Command::new("test") .about("hides long args") .author("Steve P.") .version("2.31.2") @@ -184,7 +184,7 @@ OPTIONS: #[test] fn hide_long_args_short_help() { - let app = App::new("test") + let app = Command::new("test") .about("hides long args") .author("Steve P.") .version("2.31.2") @@ -223,7 +223,7 @@ OPTIONS: #[test] fn hide_pos_args() { - let app = App::new("test").version("1.4").args(&[ + let app = Command::new("test").version("1.4").args(&[ Arg::new("pos").help("some pos").hide(true), Arg::new("another").help("another pos"), ]); @@ -248,9 +248,9 @@ OPTIONS: #[test] fn hide_subcmds() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") - .subcommand(App::new("sub").hide(true)); + .subcommand(Command::new("sub").hide(true)); assert!(utils::compare_output( app, @@ -270,7 +270,7 @@ After help #[test] fn hide_opt_args_only() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") .after_help("After help") .mut_arg("help", |a| a.hide(true)) @@ -299,7 +299,7 @@ After help #[test] fn hide_pos_args_only() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") .after_help("After help") .mut_arg("help", |a| a.hide(true)) @@ -324,12 +324,12 @@ After help #[test] fn hide_subcmds_only() { - let app = App::new("test") + let app = Command::new("test") .version("1.4") .after_help("After help") .mut_arg("help", |a| a.hide(true)) .mut_arg("version", |a| a.hide(true)) - .subcommand(App::new("sub").hide(true)); + .subcommand(Command::new("sub").hide(true)); assert!(utils::compare_output( app, diff --git a/tests/builder/ignore_errors.rs b/tests/builder/ignore_errors.rs index f3da817712b..0b1bbf785bf 100644 --- a/tests/builder/ignore_errors.rs +++ b/tests/builder/ignore_errors.rs @@ -1,8 +1,8 @@ -use clap::{arg, App, Arg}; +use clap::{arg, Arg, Command}; #[test] fn single_short_arg_without_value() { - let app = App::new("app").ignore_errors(true).arg(arg!( + let app = Command::new("app").ignore_errors(true).arg(arg!( -c --config [FILE] "Sets a custom config file" )); @@ -15,7 +15,7 @@ fn single_short_arg_without_value() { #[test] fn single_long_arg_without_value() { - let app = App::new("app").ignore_errors(true).arg(arg!( + let app = Command::new("app").ignore_errors(true).arg(arg!( -c --config [FILE] "Sets a custom config file" )); @@ -28,7 +28,7 @@ fn single_long_arg_without_value() { #[test] fn multiple_args_and_final_arg_without_value() { - let app = App::new("app") + let app = Command::new("app") .ignore_errors(true) .arg(arg!( -c --config [FILE] "Sets a custom config file" @@ -51,7 +51,7 @@ fn multiple_args_and_final_arg_without_value() { #[test] fn multiple_args_and_intermittent_arg_without_value() { - let app = App::new("app") + let app = Command::new("app") .ignore_errors(true) .arg(arg!( -c --config[FILE] "Sets a custom config file" @@ -75,10 +75,10 @@ fn multiple_args_and_intermittent_arg_without_value() { #[test] fn subcommand() { - let app = App::new("test") + let app = Command::new("test") .ignore_errors(true) .subcommand( - App::new("some") + Command::new("some") .arg( Arg::new("test") .short('t') diff --git a/tests/builder/indices.rs b/tests/builder/indices.rs index 8be1b287b63..403cf86f579 100644 --- a/tests/builder/indices.rs +++ b/tests/builder/indices.rs @@ -1,8 +1,8 @@ -use clap::{App, Arg}; +use clap::{Arg, Command}; #[test] fn indices_mult_opts() { - let m = App::new("ind") + let m = Command::new("ind") .arg( Arg::new("exclude") .short('e') @@ -31,7 +31,7 @@ fn indices_mult_opts() { #[test] fn index_mult_opts() { - let m = App::new("ind") + let m = Command::new("ind") .arg( Arg::new("exclude") .short('e') @@ -54,7 +54,7 @@ fn index_mult_opts() { #[test] fn index_flag() { - let m = App::new("ind") + let m = Command::new("ind") .arg(Arg::new("exclude").short('e')) .arg(Arg::new("include").short('i')) .try_get_matches_from(vec!["ind", "-e", "-i"]) @@ -66,7 +66,7 @@ fn index_flag() { #[test] fn index_flags() { - let m = App::new("ind") + let m = Command::new("ind") .arg(Arg::new("exclude").short('e').multiple_occurrences(true)) .arg(Arg::new("include").short('i').multiple_occurrences(true)) .try_get_matches_from(vec!["ind", "-e", "-i", "-e", "-e", "-i"]) @@ -78,7 +78,7 @@ fn index_flags() { #[test] fn indices_mult_flags() { - let m = App::new("ind") + let m = Command::new("ind") .arg(Arg::new("exclude").short('e').multiple_occurrences(true)) .arg(Arg::new("include").short('i').multiple_occurrences(true)) .try_get_matches_from(vec!["ind", "-e", "-i", "-e", "-e", "-i"]) @@ -96,7 +96,7 @@ fn indices_mult_flags() { #[test] fn indices_mult_flags_combined() { - let m = App::new("ind") + let m = Command::new("ind") .arg(Arg::new("exclude").short('e').multiple_occurrences(true)) .arg(Arg::new("include").short('i').multiple_occurrences(true)) .try_get_matches_from(vec!["ind", "-eieei"]) @@ -114,7 +114,7 @@ fn indices_mult_flags_combined() { #[test] fn indices_mult_flags_opt_combined() { - let m = App::new("ind") + let m = Command::new("ind") .arg(Arg::new("exclude").short('e').multiple_occurrences(true)) .arg(Arg::new("include").short('i').multiple_occurrences(true)) .arg(Arg::new("option").short('o').takes_value(true)) @@ -134,7 +134,7 @@ fn indices_mult_flags_opt_combined() { #[test] fn indices_mult_flags_opt_combined_eq() { - let m = App::new("ind") + let m = Command::new("ind") .arg(Arg::new("exclude").short('e').multiple_occurrences(true)) .arg(Arg::new("include").short('i').multiple_occurrences(true)) .arg(Arg::new("option").short('o').takes_value(true)) @@ -154,7 +154,7 @@ fn indices_mult_flags_opt_combined_eq() { #[test] fn indices_mult_opt_value_delim_eq() { - let m = App::new("myapp") + let m = Command::new("myapp") .arg( Arg::new("option") .short('o') @@ -172,7 +172,7 @@ fn indices_mult_opt_value_delim_eq() { #[test] fn indices_mult_opt_value_no_delim_eq() { - let m = App::new("myapp") + let m = Command::new("myapp") .arg( Arg::new("option") .short('o') @@ -186,7 +186,7 @@ fn indices_mult_opt_value_no_delim_eq() { #[test] fn indices_mult_opt_mult_flag() { - let m = App::new("myapp") + let m = Command::new("myapp") .arg( Arg::new("option") .short('o') diff --git a/tests/builder/multiple_occurrences.rs b/tests/builder/multiple_occurrences.rs index 5c78ada2ccd..3cf0fb6132f 100644 --- a/tests/builder/multiple_occurrences.rs +++ b/tests/builder/multiple_occurrences.rs @@ -1,8 +1,8 @@ -use clap::{arg, error::ErrorKind, App, Arg}; +use clap::{arg, error::ErrorKind, Arg, Command}; #[test] fn multiple_occurrences_of_flags_long() { - let m = App::new("mo_flags_long") + let m = Command::new("mo_flags_long") .arg(arg!(--multflag "allowed multiple flag").multiple_occurrences(true)) .arg(arg!(--flag "disallowed multiple flag")) .try_get_matches_from(vec!["", "--multflag", "--flag", "--multflag"]) @@ -15,7 +15,7 @@ fn multiple_occurrences_of_flags_long() { #[test] fn multiple_occurrences_of_flags_short() { - let m = App::new("mo_flags_short") + let m = Command::new("mo_flags_short") .arg(arg!(-m --multflag "allowed multiple flag").multiple_occurrences(true)) .arg(arg!(-f --flag "disallowed multiple flag")) .try_get_matches_from(vec!["", "-m", "-f", "-m"]) @@ -28,7 +28,7 @@ fn multiple_occurrences_of_flags_short() { #[test] fn multiple_occurrences_of_flags_mixed() { - let m = App::new("mo_flags_mixed") + let m = Command::new("mo_flags_mixed") .arg(arg!(-m --multflag1 "allowed multiple flag").multiple_occurrences(true)) .arg(arg!(-n --multflag2 "another allowed multiple flag").multiple_occurrences(true)) .arg(arg!(-f --flag "disallowed multiple flag")) @@ -52,7 +52,7 @@ fn multiple_occurrences_of_flags_mixed() { #[test] fn multiple_occurrences_of_positional() { - let app = App::new("test").arg(Arg::new("multi").multiple_occurrences(true)); + let app = Command::new("test").arg(Arg::new("multi").multiple_occurrences(true)); let m = app .clone() @@ -88,7 +88,7 @@ fn multiple_occurrences_of_flags_large_quantity() { .into_iter() .chain(vec!["-m"; 1024].into_iter()) .collect(); - let m = App::new("mo_flags_large_qty") + let m = Command::new("mo_flags_large_qty") .arg(arg!(-m --multflag "allowed multiple flag").multiple_occurrences(true)) .try_get_matches_from(args) .unwrap(); @@ -99,7 +99,7 @@ fn multiple_occurrences_of_flags_large_quantity() { #[cfg(feature = "env")] #[test] fn multiple_occurrences_of_before_env() { - let app = App::new("mo_before_env").arg( + let app = Command::new("mo_before_env").arg( Arg::new("verbose") .env("VERBOSE") .short('v') @@ -127,7 +127,7 @@ fn multiple_occurrences_of_before_env() { #[cfg(feature = "env")] #[test] fn multiple_occurrences_of_after_env() { - let app = App::new("mo_after_env").arg( + let app = Command::new("mo_after_env").arg( Arg::new("verbose") .short('v') .long("verbose") @@ -154,7 +154,7 @@ fn multiple_occurrences_of_after_env() { #[test] fn max_occurrences_implies_multiple_occurrences() { - let app = App::new("prog").arg( + let app = Command::new("prog").arg( Arg::new("verbose") .short('v') .long("verbose") @@ -166,7 +166,7 @@ fn max_occurrences_implies_multiple_occurrences() { assert_eq!(m.unwrap().occurrences_of("verbose"), 3); // One max should not imply multiple occurrences - let app = App::new("prog").arg( + let app = Command::new("prog").arg( Arg::new("verbose") .short('v') .long("verbose") @@ -181,7 +181,7 @@ fn max_occurrences_implies_multiple_occurrences() { #[test] fn max_occurrences_try_inputs() { - let app = App::new("prog").arg( + let app = Command::new("prog").arg( Arg::new("verbose") .short('v') .long("verbose") @@ -218,7 +218,7 @@ fn max_occurrences_try_inputs() { #[test] fn max_occurrences_positional() { - let app = App::new("prog").arg(Arg::new("verbose").max_occurrences(3)); + let app = Command::new("prog").arg(Arg::new("verbose").max_occurrences(3)); let m = app.clone().try_get_matches_from(vec!["prog", "v"]); assert!(m.is_ok(), "{}", m.unwrap_err()); assert_eq!(m.unwrap().occurrences_of("verbose"), 1); diff --git a/tests/builder/multiple_values.rs b/tests/builder/multiple_values.rs index 74a5ee50f79..3f115e76ade 100644 --- a/tests/builder/multiple_values.rs +++ b/tests/builder/multiple_values.rs @@ -1,8 +1,8 @@ -use clap::{error::ErrorKind, App, Arg}; +use clap::{error::ErrorKind, Arg, Command}; #[test] fn option_long() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -28,7 +28,7 @@ fn option_long() { #[test] fn option_short() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -52,7 +52,7 @@ fn option_short() { #[test] fn option_mixed() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -79,7 +79,7 @@ fn option_mixed() { #[test] fn option_exact_exact() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -102,7 +102,7 @@ fn option_exact_exact() { #[test] fn option_exact_exact_not_mult() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -124,7 +124,7 @@ fn option_exact_exact_not_mult() { #[test] fn option_exact_exact_mult() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -149,7 +149,7 @@ fn option_exact_exact_mult() { #[test] fn option_exact_less() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -165,7 +165,7 @@ fn option_exact_less() { #[test] fn option_exact_more() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -183,7 +183,7 @@ fn option_exact_more() { #[test] fn option_min_exact() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -206,7 +206,7 @@ fn option_min_exact() { #[test] fn option_min_less() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -222,7 +222,7 @@ fn option_min_less() { #[test] fn option_short_min_more_mult_occurs() { - let res = App::new("multiple_values") + let res = Command::new("multiple_values") .arg(Arg::new("arg").required(true)) .arg( Arg::new("option") @@ -250,7 +250,7 @@ fn option_short_min_more_mult_occurs() { #[test] fn option_short_min_more_single_occur() { - let res = App::new("multiple_values") + let res = Command::new("multiple_values") .arg(Arg::new("arg").required(true)) .arg( Arg::new("option") @@ -275,7 +275,7 @@ fn option_short_min_more_single_occur() { #[test] fn option_max_exact() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -298,7 +298,7 @@ fn option_max_exact() { #[test] fn option_max_less() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -321,7 +321,7 @@ fn option_max_less() { #[test] fn option_max_more() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -339,7 +339,7 @@ fn option_max_more() { #[test] fn positional() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("pos") .help("multiple positionals") @@ -361,7 +361,7 @@ fn positional() { #[test] fn positional_exact_exact() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("pos") .help("multiple positionals") @@ -382,7 +382,7 @@ fn positional_exact_exact() { #[test] fn positional_exact_less() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("pos") .help("multiple positionals") @@ -396,7 +396,7 @@ fn positional_exact_less() { #[test] fn positional_exact_more() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("pos") .help("multiple positionals") @@ -410,7 +410,7 @@ fn positional_exact_more() { #[test] fn positional_min_exact() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos").help("multiple positionals").min_values(3)) .try_get_matches_from(vec!["myprog", "val1", "val2", "val3"]); @@ -427,7 +427,7 @@ fn positional_min_exact() { #[test] fn positional_min_less() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos").help("multiple positionals").min_values(3)) .try_get_matches_from(vec!["myprog", "val1", "val2"]); @@ -437,7 +437,7 @@ fn positional_min_less() { #[test] fn positional_min_more() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos").help("multiple positionals").min_values(3)) .try_get_matches_from(vec!["myprog", "val1", "val2", "val3", "val4"]); @@ -454,7 +454,7 @@ fn positional_min_more() { #[test] fn positional_max_exact() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos").help("multiple positionals").max_values(3)) .try_get_matches_from(vec!["myprog", "val1", "val2", "val3"]); @@ -471,7 +471,7 @@ fn positional_max_exact() { #[test] fn positional_max_less() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos").help("multiple positionals").max_values(3)) .try_get_matches_from(vec!["myprog", "val1", "val2"]); @@ -488,7 +488,7 @@ fn positional_max_less() { #[test] fn positional_max_more() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg(Arg::new("pos").help("multiple positionals").max_values(3)) .try_get_matches_from(vec!["myprog", "val1", "val2", "val3", "val4"]); @@ -498,7 +498,7 @@ fn positional_max_more() { #[test] fn sep_long_equals() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -520,7 +520,7 @@ fn sep_long_equals() { #[test] fn sep_long_space() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -542,7 +542,7 @@ fn sep_long_space() { #[test] fn sep_short_equals() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -564,7 +564,7 @@ fn sep_short_equals() { #[test] fn sep_short_space() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -586,7 +586,7 @@ fn sep_short_space() { #[test] fn sep_short_no_space() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -608,7 +608,7 @@ fn sep_short_no_space() { #[test] fn sep_positional() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .help("multiple options") @@ -629,7 +629,7 @@ fn sep_positional() { #[test] fn different_sep() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -651,7 +651,7 @@ fn different_sep() { #[test] fn different_sep_positional() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .help("multiple options") @@ -672,7 +672,7 @@ fn different_sep_positional() { #[test] fn no_sep() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -692,7 +692,7 @@ fn no_sep() { #[test] fn no_sep_positional() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .help("multiple options") @@ -711,7 +711,7 @@ fn no_sep_positional() { #[test] fn req_delimiter_long() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -744,7 +744,7 @@ fn req_delimiter_long() { #[test] fn req_delimiter_long_with_equal() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -777,7 +777,7 @@ fn req_delimiter_long_with_equal() { #[test] fn req_delimiter_short_with_space() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -810,7 +810,7 @@ fn req_delimiter_short_with_space() { #[test] fn req_delimiter_short_with_no_space() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -843,7 +843,7 @@ fn req_delimiter_short_with_no_space() { #[test] fn req_delimiter_short_with_equal() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .short('o') @@ -876,7 +876,7 @@ fn req_delimiter_short_with_equal() { #[test] fn req_delimiter_complex() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("option") .long("option") @@ -950,7 +950,7 @@ fn req_delimiter_complex() { positional argument (i.e. the one with the highest index) *must* have \ .required(true) or .last(true) set."] fn low_index_positional_not_required() { - let _ = App::new("lip") + let _ = Command::new("lip") .arg( Arg::new("files") .index(1) @@ -968,7 +968,7 @@ fn low_index_positional_not_required() { #[should_panic = "Only one positional argument with .multiple_values(true) \ set is allowed per command, unless the second one also has .last(true) set"] fn low_index_positional_last_multiple_too() { - let _ = App::new("lip") + let _ = Command::new("lip") .arg( Arg::new("files") .index(1) @@ -992,7 +992,7 @@ fn low_index_positional_last_multiple_too() { #[should_panic = "Only the last positional argument, or second to \ last positional argument may be set to .multiple_values(true)"] fn low_index_positional_too_far_back() { - let _ = App::new("lip") + let _ = Command::new("lip") .arg( Arg::new("files") .index(1) @@ -1007,7 +1007,7 @@ fn low_index_positional_too_far_back() { #[test] fn low_index_positional() { - let m = App::new("lip") + let m = Command::new("lip") .arg( Arg::new("files") .index(1) @@ -1034,9 +1034,9 @@ fn low_index_positional() { #[test] fn low_index_positional_in_subcmd() { - let m = App::new("lip") + let m = Command::new("lip") .subcommand( - App::new("test") + Command::new("test") .arg( Arg::new("files") .index(1) @@ -1065,7 +1065,7 @@ fn low_index_positional_in_subcmd() { #[test] fn low_index_positional_with_option() { - let m = App::new("lip") + let m = Command::new("lip") .arg( Arg::new("files") .required(true) @@ -1096,7 +1096,7 @@ fn low_index_positional_with_option() { #[test] fn low_index_positional_with_flag() { - let m = App::new("lip") + let m = Command::new("lip") .arg( Arg::new("files") .index(1) @@ -1125,7 +1125,7 @@ fn low_index_positional_with_flag() { #[test] fn multiple_value_terminator_option() { - let m = App::new("lip") + let m = Command::new("lip") .arg( Arg::new("files") .short('f') @@ -1151,7 +1151,7 @@ fn multiple_value_terminator_option() { #[test] fn multiple_value_terminator_option_other_arg() { - let m = App::new("lip") + let m = Command::new("lip") .arg( Arg::new("files") .short('f') @@ -1178,7 +1178,7 @@ fn multiple_value_terminator_option_other_arg() { #[test] fn multiple_vals_with_hyphen() { - let res = App::new("do") + let res = Command::new("do") .arg( Arg::new("cmds") .takes_value(true) @@ -1207,7 +1207,7 @@ fn multiple_vals_with_hyphen() { #[test] fn issue_1480_max_values_consumes_extra_arg_1() { - let res = App::new("prog") + let res = Command::new("prog") .arg(Arg::new("field").max_values(1).long("field")) .arg(Arg::new("positional").required(true).index(1)) .try_get_matches_from(vec!["prog", "--field", "1", "file"]); @@ -1217,7 +1217,7 @@ fn issue_1480_max_values_consumes_extra_arg_1() { #[test] fn issue_1480_max_values_consumes_extra_arg_2() { - let res = App::new("prog") + let res = Command::new("prog") .arg(Arg::new("field").max_values(1).long("field")) .try_get_matches_from(vec!["prog", "--field", "1", "2"]); @@ -1227,7 +1227,7 @@ fn issue_1480_max_values_consumes_extra_arg_2() { #[test] fn issue_1480_max_values_consumes_extra_arg_3() { - let res = App::new("prog") + let res = Command::new("prog") .arg(Arg::new("field").max_values(1).long("field")) .try_get_matches_from(vec!["prog", "--field", "1", "2", "3"]); @@ -1237,7 +1237,7 @@ fn issue_1480_max_values_consumes_extra_arg_3() { #[test] fn issue_2229() { - let m = App::new("multiple_values") + let m = Command::new("multiple_values") .arg( Arg::new("pos") .help("multiple positionals") @@ -1253,7 +1253,7 @@ fn issue_2229() { #[test] fn value_names_building_num_vals() { - let m = App::new("test") + let m = Command::new("test") .arg( Arg::new("pos") .long("pos") @@ -1272,7 +1272,7 @@ fn value_names_building_num_vals() { #[test] fn value_names_building_num_vals_for_positional() { - let m = App::new("test") + let m = Command::new("test") .arg(Arg::new("pos").value_names(&["who", "what", "why"])) .try_get_matches_from(vec!["myprog", "val1", "val2", "val3"]); @@ -1287,7 +1287,7 @@ fn value_names_building_num_vals_for_positional() { #[test] fn number_of_values_preferred_over_value_names() { - let m = App::new("test") + let m = Command::new("test") .arg( Arg::new("pos") .long("pos") @@ -1307,7 +1307,7 @@ fn number_of_values_preferred_over_value_names() { #[test] fn values_per_occurrence_named() { - let mut a = App::new("test").arg( + let mut a = Command::new("test").arg( Arg::new("pos") .long("pos") .number_of_values(2) @@ -1339,7 +1339,7 @@ fn values_per_occurrence_named() { #[test] fn values_per_occurrence_positional() { - let mut a = App::new("test").arg( + let mut a = Command::new("test").arg( Arg::new("pos") .number_of_values(2) .multiple_occurrences(true), diff --git a/tests/builder/opts.rs b/tests/builder/opts.rs index 74f11af491f..aeb0a5c191c 100644 --- a/tests/builder/opts.rs +++ b/tests/builder/opts.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{arg, error::ErrorKind, App, Arg, ArgMatches}; +use clap::{arg, error::ErrorKind, Arg, ArgMatches, Command}; #[cfg(feature = "suggestions")] static DYM: &str = @@ -32,7 +32,7 @@ For more information try --help #[test] fn require_equals_fail() { - let res = App::new("prog") + let res = Command::new("prog") .arg( Arg::new("cfg") .require_equals(true) @@ -55,7 +55,7 @@ USAGE: For more information try --help "; - let app = App::new("prog").arg( + let app = Command::new("prog").arg( Arg::new("cfg") .require_equals(true) .takes_value(true) @@ -71,7 +71,7 @@ For more information try --help #[test] fn require_equals_min_values_zero() { - let res = App::new("prog") + let res = Command::new("prog") .arg( Arg::new("cfg") .takes_value(true) @@ -89,7 +89,7 @@ fn require_equals_min_values_zero() { #[test] fn double_hyphen_as_value() { - let res = App::new("prog") + let res = Command::new("prog") .arg( Arg::new("cfg") .takes_value(true) @@ -103,7 +103,7 @@ fn double_hyphen_as_value() { #[test] fn require_equals_no_empty_values_fail() { - let res = App::new("prog") + let res = Command::new("prog") .arg( Arg::new("cfg") .takes_value(true) @@ -119,7 +119,7 @@ fn require_equals_no_empty_values_fail() { #[test] fn require_equals_empty_vals_pass() { - let res = App::new("prog") + let res = Command::new("prog") .arg( Arg::new("cfg") .takes_value(true) @@ -132,7 +132,7 @@ fn require_equals_empty_vals_pass() { #[test] fn require_equals_pass() { - let res = App::new("prog") + let res = Command::new("prog") .arg( Arg::new("cfg") .takes_value(true) @@ -145,7 +145,7 @@ fn require_equals_pass() { #[test] fn stdin_char() { - let r = App::new("opts") + let r = Command::new("opts") .arg(arg!(f: -f [flag] "some flag")) .try_get_matches_from(vec!["", "-f", "-"]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -156,7 +156,7 @@ fn stdin_char() { #[test] fn opts_using_short() { - let r = App::new("opts") + let r = Command::new("opts") .args(&[ arg!(f: -f [flag] "some flag"), arg!(c: -c [color] "some other flag"), @@ -172,7 +172,7 @@ fn opts_using_short() { #[test] fn lots_o_vals() { - let r = App::new("opts") + let r = Command::new("opts") .arg(arg!(o: -o "some opt").multiple_values(true)) .try_get_matches_from(vec![ "", "-o", "some", "some", "some", "some", "some", "some", "some", "some", "some", @@ -212,7 +212,7 @@ fn lots_o_vals() { #[test] fn opts_using_long_space() { - let r = App::new("opts") + let r = Command::new("opts") .args(&[ arg!(--flag [flag] "some flag"), arg!(--color [color] "some other flag"), @@ -228,7 +228,7 @@ fn opts_using_long_space() { #[test] fn opts_using_long_equals() { - let r = App::new("opts") + let r = Command::new("opts") .args(&[ arg!(--flag [flag] "some flag"), arg!(--color [color] "some other flag"), @@ -244,7 +244,7 @@ fn opts_using_long_equals() { #[test] fn opts_using_mixed() { - let r = App::new("opts") + let r = Command::new("opts") .args(&[ arg!(-f --flag [flag] "some flag"), arg!(-c --color [color] "some other flag"), @@ -260,7 +260,7 @@ fn opts_using_mixed() { #[test] fn opts_using_mixed2() { - let r = App::new("opts") + let r = Command::new("opts") .args(&[ arg!(-f --flag [flag] "some flag"), arg!(-c --color [color] "some other flag"), @@ -276,7 +276,7 @@ fn opts_using_mixed2() { #[test] fn default_values_user_value() { - let r = App::new("df") + let r = Command::new("df") .arg(arg!(o: -o [opt] "some opt").default_value("default")) .try_get_matches_from(vec!["", "-o", "value"]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -287,7 +287,7 @@ fn default_values_user_value() { #[test] fn multiple_vals_pos_arg_equals() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg(arg!(o: -o [opt] ... "some opt")) .arg(arg!([file] "some file")) .try_get_matches_from(vec!["", "-o=1", "some"]); @@ -301,7 +301,7 @@ fn multiple_vals_pos_arg_equals() { #[test] fn multiple_vals_pos_arg_delim() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg( arg!(o: -o "some opt") .multiple_values(true) @@ -319,7 +319,7 @@ fn multiple_vals_pos_arg_delim() { #[test] fn require_delims_no_delim() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg( arg!(o: -o [opt] ... "some opt") .use_value_delimiter(true) @@ -334,7 +334,7 @@ fn require_delims_no_delim() { #[test] fn require_delims() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg( arg!(o: -o "some opt") .multiple_values(true) @@ -353,7 +353,7 @@ fn require_delims() { #[test] fn leading_hyphen_pass() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg( arg!(o: -o "some opt") .multiple_values(true) @@ -368,7 +368,7 @@ fn leading_hyphen_pass() { #[test] fn leading_hyphen_fail() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg(arg!(o: -o "some opt")) .try_get_matches_from(vec!["", "-o", "-2"]); assert!(r.is_err()); @@ -378,7 +378,7 @@ fn leading_hyphen_fail() { #[test] fn leading_hyphen_with_flag_after() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg( arg!(o: -o "some opt") .multiple_values(true) @@ -395,7 +395,7 @@ fn leading_hyphen_with_flag_after() { #[test] fn leading_hyphen_with_flag_before() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg(arg!(o: -o [opt] ... "some opt").allow_hyphen_values(true)) .arg(arg!(f: -f "some flag")) .try_get_matches_from(vec!["", "-f", "-o", "-2"]); @@ -408,7 +408,7 @@ fn leading_hyphen_with_flag_before() { #[test] fn leading_hyphen_with_only_pos_follows() { - let r = App::new("mvae") + let r = Command::new("mvae") .arg( arg!(o: -o [opt] ... "some opt") .number_of_values(1) @@ -437,7 +437,7 @@ fn did_you_mean() { #[test] fn issue_1047_min_zero_vals_default_val() { - let m = App::new("foo") + let m = Command::new("foo") .arg( Arg::new("del") .short('d') @@ -454,7 +454,7 @@ fn issue_1047_min_zero_vals_default_val() { } fn issue_1105_setup(argv: Vec<&'static str>) -> Result { - App::new("opts") + Command::new("opts") .arg(arg!(-o --option "some option")) .arg(arg!(--flag "some flag")) .try_get_matches_from(argv) @@ -517,7 +517,7 @@ fn issue_1105_empty_value_short_explicit_no_space() { #[test] #[cfg(feature = "suggestions")] fn issue_1073_suboptimal_flag_suggestion() { - let app = App::new("ripgrep-616") + let app = Command::new("ripgrep-616") .arg(Arg::new("files-with-matches").long("files-with-matches")) .arg(Arg::new("files-without-match").long("files-without-match")); assert!(utils::compare_output( @@ -530,7 +530,7 @@ fn issue_1073_suboptimal_flag_suggestion() { #[test] fn short_non_ascii_no_space() { - let matches = App::new("app") + let matches = Command::new("app") .arg(arg!(opt: -'磨' )) .try_get_matches_from(&["test", "-磨VALUE"]) .unwrap(); @@ -540,7 +540,7 @@ fn short_non_ascii_no_space() { #[test] fn short_eq_val_starts_with_eq() { - let matches = App::new("app") + let matches = Command::new("app") .arg(arg!(opt: -f )) .try_get_matches_from(&["test", "-f==value"]) .unwrap(); @@ -550,7 +550,7 @@ fn short_eq_val_starts_with_eq() { #[test] fn long_eq_val_starts_with_eq() { - let matches = App::new("app") + let matches = Command::new("app") .arg(arg!(opt: --foo )) .try_get_matches_from(&["test", "--foo==value"]) .unwrap(); @@ -560,7 +560,7 @@ fn long_eq_val_starts_with_eq() { #[test] fn issue_2022_get_flags_misuse() { - let app = App::new("test") + let app = Command::new("test") .next_help_heading(Some("test")) .arg(Arg::new("a").long("a").default_value("32")); let matches = app.try_get_matches_from(&[""]).unwrap(); @@ -569,7 +569,7 @@ fn issue_2022_get_flags_misuse() { #[test] fn issue_2279() { - let before_help_heading = App::new("app") + let before_help_heading = Command::new("app") .arg(Arg::new("foo").short('f').default_value("bar")) .next_help_heading(Some("This causes default_value to be ignored")) .try_get_matches_from(&[""]) @@ -577,7 +577,7 @@ fn issue_2279() { assert_eq!(before_help_heading.value_of("foo"), Some("bar")); - let after_help_heading = App::new("app") + let after_help_heading = Command::new("app") .next_help_heading(Some("This causes default_value to be ignored")) .arg(Arg::new("foo").short('f').default_value("bar")) .try_get_matches_from(&[""]) @@ -588,7 +588,7 @@ fn issue_2279() { #[test] fn infer_long_arg() { - let app = App::new("test") + let app = Command::new("test") .infer_long_args(true) .arg(Arg::new("racetrack").long("racetrack").alias("autobahn")) .arg(Arg::new("racecar").long("racecar").takes_value(true)); @@ -614,7 +614,7 @@ fn infer_long_arg() { assert!(matches.is_present("racetrack")); assert_eq!(matches.value_of("racecar"), None); - let app = App::new("test") + let app = Command::new("test") .infer_long_args(true) .arg(Arg::new("arg").long("arg")); diff --git a/tests/builder/positionals.rs b/tests/builder/positionals.rs index 485f3e4f1c3..c3ebd06821c 100644 --- a/tests/builder/positionals.rs +++ b/tests/builder/positionals.rs @@ -1,8 +1,8 @@ -use clap::{arg, error::ErrorKind, App, Arg}; +use clap::{arg, error::ErrorKind, Arg, Command}; #[test] fn only_pos_follow() { - let r = App::new("onlypos") + let r = Command::new("onlypos") .args(&[arg!(f: -f [flag] "some opt"), arg!([arg] "some arg")]) .try_get_matches_from(vec!["", "--", "-f"]); assert!(r.is_ok(), "{}", r.unwrap_err()); @@ -14,7 +14,7 @@ fn only_pos_follow() { #[test] fn issue_946() { - let r = App::new("compiletest") + let r = Command::new("compiletest") .allow_hyphen_values(true) .arg(arg!(--exact "filters match exactly")) .arg( @@ -33,7 +33,7 @@ fn issue_946() { #[test] fn positional() { - let r = App::new("positional") + let r = Command::new("positional") .args(&[arg!(-f --flag "some flag"), Arg::new("positional").index(1)]) .try_get_matches_from(vec!["", "-f", "test"]); assert!(r.is_ok(), "{:#?}", r); @@ -42,7 +42,7 @@ fn positional() { assert!(m.is_present("flag")); assert_eq!(m.value_of("positional").unwrap(), "test"); - let m = App::new("positional") + let m = Command::new("positional") .args(&[arg!(-f --flag "some flag"), Arg::new("positional").index(1)]) .try_get_matches_from(vec!["", "test", "--flag"]) .unwrap(); @@ -53,7 +53,7 @@ fn positional() { #[test] fn lots_o_vals() { - let r = App::new("opts") + let r = Command::new("opts") .arg(arg!(... "some pos")) .try_get_matches_from(vec![ "", "some", "some", "some", "some", "some", "some", "some", "some", "some", "some", @@ -93,7 +93,7 @@ fn lots_o_vals() { #[test] fn positional_multiple() { - let r = App::new("positional_multiple") + let r = Command::new("positional_multiple") .args(&[ arg!(-f --flag "some flag"), Arg::new("positional") @@ -114,7 +114,7 @@ fn positional_multiple() { #[test] fn positional_multiple_3() { - let r = App::new("positional_multiple") + let r = Command::new("positional_multiple") .args(&[ arg!(-f --flag "some flag"), Arg::new("positional") @@ -135,7 +135,7 @@ fn positional_multiple_3() { #[test] fn positional_multiple_2() { - let result = App::new("positional_multiple") + let result = Command::new("positional_multiple") .args(&[arg!(-f --flag "some flag"), Arg::new("positional").index(1)]) .try_get_matches_from(vec!["", "-f", "test1", "test2", "test3"]); assert!(result.is_err()); @@ -145,7 +145,7 @@ fn positional_multiple_2() { #[test] fn positional_possible_values() { - let r = App::new("positional_possible_values") + let r = Command::new("positional_possible_values") .args(&[ arg!(-f --flag "some flag"), Arg::new("positional").index(1).possible_value("test123"), @@ -163,7 +163,7 @@ fn positional_possible_values() { #[test] fn create_positional() { - let _ = App::new("test") + let _ = Command::new("test") .arg(Arg::new("test").index(1).help("testing testing")) .try_get_matches_from(vec![""]) .unwrap(); @@ -171,7 +171,7 @@ fn create_positional() { #[test] fn positional_hyphen_does_not_panic() { - let _ = App::new("test") + let _ = Command::new("test") .arg(Arg::new("dummy")) .try_get_matches_from(vec!["test", "-"]) .unwrap(); @@ -179,19 +179,19 @@ fn positional_hyphen_does_not_panic() { #[test] fn single_positional_usage_string() { - let mut app = App::new("test").arg(arg!([FILE] "some file")); + let mut app = Command::new("test").arg(arg!([FILE] "some file")); assert_eq!(app.render_usage(), "USAGE:\n test [FILE]"); } #[test] fn single_positional_multiple_usage_string() { - let mut app = App::new("test").arg(arg!([FILE]... "some file")); + let mut app = Command::new("test").arg(arg!([FILE]... "some file")); assert_eq!(app.render_usage(), "USAGE:\n test [FILE]..."); } #[test] fn multiple_positional_usage_string() { - let mut app = App::new("test") + let mut app = Command::new("test") .arg(arg!([FILE] "some file")) .arg(arg!([FILES]... "some file")); assert_eq!(app.render_usage(), "USAGE:\n test [ARGS]"); @@ -199,7 +199,7 @@ fn multiple_positional_usage_string() { #[test] fn multiple_positional_one_required_usage_string() { - let mut app = App::new("test") + let mut app = Command::new("test") .arg(arg!( "some file")) .arg(arg!([FILES]... "some file")); assert_eq!(app.render_usage(), "USAGE:\n test [FILES]..."); @@ -207,7 +207,7 @@ fn multiple_positional_one_required_usage_string() { #[test] fn single_positional_required_usage_string() { - let mut app = App::new("test").arg(arg!( "some file")); + let mut app = Command::new("test").arg(arg!( "some file")); assert_eq!(app.render_usage(), "USAGE:\n test "); } @@ -217,7 +217,7 @@ fn single_positional_required_usage_string() { #[should_panic = "Found non-required positional argument \ with a lower index than a required positional argument"] fn missing_required() { - let _ = App::new("test") + let _ = Command::new("test") .arg(arg!([FILE1] "some file")) .arg(arg!( "some file")) .try_get_matches_from(vec![""]); @@ -225,7 +225,7 @@ fn missing_required() { #[test] fn missing_required_2() { - let r = App::new("test") + let r = Command::new("test") .arg(arg!( "some file")) .arg(arg!( "some file")) .try_get_matches_from(vec!["test", "file"]); @@ -235,7 +235,7 @@ fn missing_required_2() { #[test] fn last_positional() { - let r = App::new("test") + let r = Command::new("test") .arg(arg!( "some target")) .arg(arg!([CORPUS] "some corpus")) .arg(arg!([ARGS]... "some file").last(true)) @@ -247,7 +247,7 @@ fn last_positional() { #[test] fn last_positional_no_double_dash() { - let r = App::new("test") + let r = Command::new("test") .arg(arg!( "some target")) .arg(arg!([CORPUS] "some corpus")) .arg(arg!([ARGS]... "some file").last(true)) @@ -258,7 +258,7 @@ fn last_positional_no_double_dash() { #[test] fn last_positional_second_to_last_mult() { - let r = App::new("test") + let r = Command::new("test") .arg(arg!( "some target")) .arg(arg!([CORPUS]... "some corpus")) .arg(arg!([ARGS]... "some file").last(true)) @@ -270,9 +270,9 @@ fn last_positional_second_to_last_mult() { #[test] #[should_panic = "Argument 'arg' is a positional argument and can't have short or long name versions"] fn positional_arg_with_long() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg(Arg::new("arg").index(1).long("arg")) .try_get_matches(); } @@ -281,16 +281,16 @@ fn positional_arg_with_long() { #[test] #[should_panic = "Argument 'arg' is a positional argument and can't have short or long name versions"] fn positional_arg_with_short() { - use clap::{App, Arg}; + use clap::{Arg, Command}; - let _ = App::new("test") + let _ = Command::new("test") .arg(Arg::new("arg").index(1).short('a')) .try_get_matches(); } #[test] fn ignore_hyphen_values_on_last() { - let app = clap::App::new("foo") + let app = clap::Command::new("foo") .arg( clap::Arg::new("cmd") .multiple_values(true) diff --git a/tests/builder/posix_compatible.rs b/tests/builder/posix_compatible.rs index 30d67f0f08d..a8fc271eedf 100644 --- a/tests/builder/posix_compatible.rs +++ b/tests/builder/posix_compatible.rs @@ -1,8 +1,8 @@ -use clap::{arg, error::ErrorKind, App, Arg}; +use clap::{arg, error::ErrorKind, Arg, Command}; #[test] fn flag_overrides_itself() { - let res = App::new("posix") + let res = Command::new("posix") .arg( arg!(--flag "some flag" ) @@ -17,7 +17,7 @@ fn flag_overrides_itself() { #[test] fn mult_flag_overrides_itself() { - let res = App::new("posix") + let res = Command::new("posix") .arg(arg!(--flag ... "some flag").overrides_with("flag")) .try_get_matches_from(vec!["", "--flag", "--flag", "--flag", "--flag"]); assert!(res.is_ok(), "{}", res.unwrap_err()); @@ -28,7 +28,7 @@ fn mult_flag_overrides_itself() { #[test] fn option_overrides_itself() { - let res = App::new("posix") + let res = Command::new("posix") .arg( arg!(--opt "some option") .required(false) @@ -44,7 +44,7 @@ fn option_overrides_itself() { #[test] fn mult_option_require_delim_overrides_itself() { - let res = App::new("posix") + let res = Command::new("posix") .arg( arg!(--opt ... "some option") .required(false) @@ -67,7 +67,7 @@ fn mult_option_require_delim_overrides_itself() { #[test] fn mult_option_overrides_itself() { - let res = App::new("posix") + let res = Command::new("posix") .arg( arg!(--opt ... "some option") .required(false) @@ -96,7 +96,7 @@ fn mult_option_overrides_itself() { #[test] fn option_use_delim_false_override_itself() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(--opt "some option") .required(false) @@ -115,7 +115,7 @@ fn option_use_delim_false_override_itself() { #[test] fn pos_mult_overrides_itself() { // opts with multiple - let res = App::new("posix") + let res = Command::new("posix") .arg(arg!([val] ... "some pos").overrides_with("val")) .try_get_matches_from(vec!["", "some", "other", "value"]); assert!(res.is_ok(), "{}", res.unwrap_err()); @@ -129,7 +129,7 @@ fn pos_mult_overrides_itself() { } #[test] fn posix_compatible_flags_long() { - let m = App::new("posix") + let m = Command::new("posix") .arg(arg!(--flag "some flag").overrides_with("color")) .arg(arg!(--color "some other flag")) .try_get_matches_from(vec!["", "--flag", "--color"]) @@ -140,7 +140,7 @@ fn posix_compatible_flags_long() { #[test] fn posix_compatible_flags_long_rev() { - let m = App::new("posix") + let m = Command::new("posix") .arg(arg!(--flag "some flag").overrides_with("color")) .arg(arg!(--color "some other flag")) .try_get_matches_from(vec!["", "--color", "--flag"]) @@ -151,7 +151,7 @@ fn posix_compatible_flags_long_rev() { #[test] fn posix_compatible_flags_short() { - let m = App::new("posix") + let m = Command::new("posix") .arg(arg!(-f --flag "some flag").overrides_with("color")) .arg(arg!(-c --color "some other flag")) .try_get_matches_from(vec!["", "-f", "-c"]) @@ -162,7 +162,7 @@ fn posix_compatible_flags_short() { #[test] fn posix_compatible_flags_short_rev() { - let m = App::new("posix") + let m = Command::new("posix") .arg(arg!(-f --flag "some flag").overrides_with("color")) .arg(arg!(-c --color "some other flag")) .try_get_matches_from(vec!["", "-c", "-f"]) @@ -173,7 +173,7 @@ fn posix_compatible_flags_short_rev() { #[test] fn posix_compatible_opts_long() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(--flag "some flag") .required(false) @@ -189,7 +189,7 @@ fn posix_compatible_opts_long() { #[test] fn posix_compatible_opts_long_rev() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(--flag "some flag") .required(false) @@ -205,7 +205,7 @@ fn posix_compatible_opts_long_rev() { #[test] fn posix_compatible_opts_long_equals() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(--flag "some flag") .required(false) @@ -221,7 +221,7 @@ fn posix_compatible_opts_long_equals() { #[test] fn posix_compatible_opts_long_equals_rev() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(--flag "some flag") .required(false) @@ -237,7 +237,7 @@ fn posix_compatible_opts_long_equals_rev() { #[test] fn posix_compatible_opts_short() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(f: -f "some flag") .required(false) @@ -253,7 +253,7 @@ fn posix_compatible_opts_short() { #[test] fn posix_compatible_opts_short_rev() { - let m = App::new("posix") + let m = Command::new("posix") .arg( arg!(f: -f "some flag") .required(false) @@ -269,7 +269,7 @@ fn posix_compatible_opts_short_rev() { #[test] fn conflict_overridden() { - let m = App::new("conflict_overridden") + let m = Command::new("conflict_overridden") .arg(arg!(-f --flag "some flag").conflicts_with("debug")) .arg(arg!(-d --debug "other flag")) .arg(arg!(-c --color "third flag").overrides_with("flag")) @@ -282,7 +282,7 @@ fn conflict_overridden() { #[test] fn conflict_overridden_2() { - let result = App::new("conflict_overridden") + let result = Command::new("conflict_overridden") .arg(arg!(-f --flag "some flag").conflicts_with("debug")) .arg(arg!(-d --debug "other flag")) .arg(arg!(-c --color "third flag").overrides_with("flag")) @@ -296,7 +296,7 @@ fn conflict_overridden_2() { #[test] fn conflict_overridden_3() { - let result = App::new("conflict_overridden") + let result = Command::new("conflict_overridden") .arg(arg!(-f --flag "some flag").conflicts_with("debug")) .arg(arg!(-d --debug "other flag")) .arg(arg!(-c --color "third flag").overrides_with("flag")) @@ -308,7 +308,7 @@ fn conflict_overridden_3() { #[test] fn conflict_overridden_4() { - let m = App::new("conflict_overridden") + let m = Command::new("conflict_overridden") .arg(arg!(-f --flag "some flag").conflicts_with("debug")) .arg(arg!(-d --debug "other flag")) .arg(arg!(-c --color "third flag").overrides_with("flag")) @@ -321,7 +321,7 @@ fn conflict_overridden_4() { #[test] fn pos_required_overridden_by_flag() { - let result = App::new("require_overridden") + let result = Command::new("require_overridden") .arg(Arg::new("pos").index(1).required(true)) .arg(arg!(-c --color "some flag").overrides_with("pos")) .try_get_matches_from(vec!["", "test", "-c"]); @@ -330,7 +330,7 @@ fn pos_required_overridden_by_flag() { #[test] fn require_overridden_2() { - let m = App::new("require_overridden") + let m = Command::new("require_overridden") .arg(Arg::new("req_pos").required(true)) .arg(arg!(-c --color "other flag").overrides_with("req_pos")) .try_get_matches_from(vec!["", "-c", "req_pos"]) @@ -341,7 +341,7 @@ fn require_overridden_2() { #[test] fn require_overridden_3() { - let m = App::new("require_overridden") + let m = Command::new("require_overridden") .arg(arg!(-f --flag "some flag").requires("debug")) .arg(arg!(-d --debug "other flag")) .arg(arg!(-c --color "third flag").overrides_with("flag")) @@ -354,7 +354,7 @@ fn require_overridden_3() { #[test] fn require_overridden_4() { - let result = App::new("require_overridden") + let result = Command::new("require_overridden") .arg(arg!(-f --flag "some flag").requires("debug")) .arg(arg!(-d --debug "other flag")) .arg(arg!(-c --color "third flag").overrides_with("flag")) @@ -366,7 +366,7 @@ fn require_overridden_4() { #[test] fn issue_1374_overrides_self_with_multiple_values() { - let app = App::new("test").arg( + let app = Command::new("test").arg( Arg::new("input") .long("input") .takes_value(true) @@ -390,7 +390,7 @@ fn issue_1374_overrides_self_with_multiple_values() { #[test] fn incremental_override() { - let mut app = App::new("test") + let mut app = Command::new("test") .arg(arg!(--name ).multiple_occurrences(true)) .arg(arg!(--"no-name").overrides_with("name")); let m = app diff --git a/tests/builder/possible_values.rs b/tests/builder/possible_values.rs index 533e0ebf782..61f87ebd39d 100644 --- a/tests/builder/possible_values.rs +++ b/tests/builder/possible_values.rs @@ -1,6 +1,6 @@ use crate::utils; -use clap::{error::ErrorKind, App, Arg, PossibleValue}; +use clap::{error::ErrorKind, Arg, Command, PossibleValue}; #[cfg(feature = "suggestions")] static PV_ERROR: &str = "error: \"slo\" isn't a valid value for '-O