From 8d1da2dee3a7f4ecfe73cbb5b59ba3588fe640b2 Mon Sep 17 00:00:00 2001 From: Kevin Knapp Date: Wed, 21 Nov 2018 11:15:53 -0500 Subject: [PATCH] refactor: removes Arg::with_name in favor of Arg::new --- README.md | 8 +- benches/02_simple.rs | 4 +- benches/03_complex.rs | 28 +++--- benches/04_new_help.rs | 32 +++--- benches/05_ripgrep.rs | 2 +- benches/06_rustup.rs | 86 ++++++++-------- examples/01b_quick_example.rs | 10 +- examples/03_args.rs | 10 +- examples/04_using_matches.rs | 6 +- examples/05_flag_args.rs | 2 +- examples/06_positional_args.rs | 4 +- examples/07_option_args.rs | 2 +- examples/08_subcommands.rs | 2 +- examples/10_default_values.rs | 4 +- examples/11_only_specific_values.rs | 2 +- examples/14_groups.rs | 2 +- examples/15_custom_validator.rs | 2 +- examples/20_subcommands.rs | 6 +- examples/21_aliases.rs | 2 +- examples/22_stop_parsing_with_--.rs | 6 +- tests/app_settings.rs | 42 ++++---- tests/arg_aliases.rs | 18 ++-- tests/borrowed.rs | 6 +- tests/default_vals.rs | 14 +-- tests/delimiters.rs | 14 +-- tests/derive_order.rs | 64 ++++++------ tests/global_args.rs | 4 +- tests/help.rs | 96 +++++++++--------- tests/hidden_args.rs | 18 ++-- tests/indices.rs | 44 ++++----- tests/multiple_values.rs | 146 ++++++++++++++-------------- tests/opts.rs | 18 ++-- tests/positionals.rs | 18 ++-- tests/posix_compatible.rs | 4 +- tests/possible_values.rs | 24 ++--- tests/propagate_globals.rs | 4 +- tests/require.rs | 136 +++++++++++++------------- tests/subcommands.rs | 20 ++-- tests/tests.rs | 4 +- tests/unique_args.rs | 12 +-- 40 files changed, 463 insertions(+), 463 deletions(-) diff --git a/README.md b/README.md index f572e6da..97bd9b71 100644 --- a/README.md +++ b/README.md @@ -239,17 +239,17 @@ fn main() { .version("1.0") .author("Kevin K. ") .about("Does awesome things") - .arg(Arg::with_name("config") + .arg(Arg::new("config") .short('c') .long("config") .value_name("FILE") .help("Sets a custom config file") .takes_value(true)) - .arg(Arg::with_name("INPUT") + .arg(Arg::new("INPUT") .help("Sets the input file to use") .required(true) .index(1)) - .arg(Arg::with_name("v") + .arg(Arg::new("v") .short('v') .multiple(true) .help("Sets the level of verbosity")) @@ -257,7 +257,7 @@ fn main() { .about("controls testing features") .version("1.3") .author("Someone E. ") - .arg(Arg::with_name("debug") + .arg(Arg::new("debug") .short('d') .help("print debug information verbosely"))) .get_matches(); diff --git a/benches/02_simple.rs b/benches/02_simple.rs index c7be443d..6805f63f 100644 --- a/benches/02_simple.rs +++ b/benches/02_simple.rs @@ -60,7 +60,7 @@ fn add_opt_ref(b: &mut Bencher) { fn add_pos(b: &mut Bencher) { fn build_app() -> App<'static, 'static> { App::new("claptests") } - b.iter(|| build_app().arg(Arg::with_name("some"))); + b.iter(|| build_app().arg(Arg::new("some"))); } #[bench] @@ -68,7 +68,7 @@ fn add_pos_ref(b: &mut Bencher) { fn build_app() -> App<'static, 'static> { App::new("claptests") } b.iter(|| { - let arg = Arg::with_name("some"); + let arg = Arg::new("some"); build_app().arg(&arg) }); } diff --git a/benches/03_complex.rs b/benches/03_complex.rs index d4adb669..7cf42fdf 100644 --- a/benches/03_complex.rs +++ b/benches/03_complex.rs @@ -59,7 +59,7 @@ fn create_app_builder(b: &mut Bencher) { .about("tests clap library") .author("Kevin K. ") .arg( - Arg::with_name("opt") + Arg::new("opt") .help("tests options") .short('o') .long("option") @@ -67,26 +67,26 @@ fn create_app_builder(b: &mut Bencher) { .setting(ArgSettings::MultipleOccurrences), ) .arg( - Arg::with_name("positional") + Arg::new("positional") .help("tests positionals") .index(1), ) .arg( - Arg::with_name("flag") + Arg::new("flag") .short('f') .help("tests flags") .long("flag") .settings(&[ArgSettings::MultipleOccurrences, ArgSettings::Global]), ) .arg( - Arg::with_name("flag2") + Arg::new("flag2") .short('F') .help("tests flags with exclusions") .conflicts_with("flag") .requires("option2"), ) .arg( - Arg::with_name("option2") + Arg::new("option2") .help("tests long options with exclusions") .conflicts_with("option") .requires("positional2") @@ -94,12 +94,12 @@ fn create_app_builder(b: &mut Bencher) { .long("long-option-2"), ) .arg( - Arg::with_name("positional2") + Arg::new("positional2") .index(3) .help("tests positionals with exclusions"), ) .arg( - Arg::with_name("option3") + Arg::new("option3") .short('O') .long("Option") .setting(ArgSettings::TakesValue) @@ -107,7 +107,7 @@ fn create_app_builder(b: &mut Bencher) { .possible_values(&OPT3_VALS), ) .arg( - Arg::with_name("positional3") + Arg::new("positional3") .setting(ArgSettings::MultipleValues) .setting(ArgSettings::MultipleOccurrences) .help("tests positionals with specific values") @@ -115,13 +115,13 @@ fn create_app_builder(b: &mut Bencher) { .possible_values(&POS3_VALS), ) .arg( - Arg::with_name("multvals") + Arg::new("multvals") .long("multvals") .help("Tests mutliple values, not mult occs") .value_names(&["one", "two"]), ) .arg( - Arg::with_name("multvalsmo") + Arg::new("multvalsmo") .long("multvalsmo") .setting(ArgSettings::MultipleValues) .setting(ArgSettings::MultipleOccurrences) @@ -129,7 +129,7 @@ fn create_app_builder(b: &mut Bencher) { .value_names(&["one", "two"]), ) .arg( - Arg::with_name("minvals") + Arg::new("minvals") .long("minvals2") .setting(ArgSettings::MultipleValues) .setting(ArgSettings::MultipleOccurrences) @@ -137,7 +137,7 @@ fn create_app_builder(b: &mut Bencher) { .min_values(2), ) .arg( - Arg::with_name("maxvals") + Arg::new("maxvals") .long("maxvals3") .setting(ArgSettings::MultipleValues) .setting(ArgSettings::MultipleOccurrences) @@ -150,7 +150,7 @@ fn create_app_builder(b: &mut Bencher) { .version("0.1") .author("Kevin K. ") .arg( - Arg::with_name("scoption") + Arg::new("scoption") .short('o') .long("option") .setting(ArgSettings::MultipleValues) @@ -158,7 +158,7 @@ fn create_app_builder(b: &mut Bencher) { .help("tests options"), ) .arg( - Arg::with_name("scpositional") + Arg::new("scpositional") .index(1) .help("tests positionals"), ), diff --git a/benches/04_new_help.rs b/benches/04_new_help.rs index 9d419630..a6146113 100644 --- a/benches/04_new_help.rs +++ b/benches/04_new_help.rs @@ -42,17 +42,17 @@ fn app_example2<'b, 'c>() -> App<'b, 'c> { fn app_example3<'b, 'c>() -> App<'b, 'c> { App::new("MyApp") .arg( - Arg::with_name("debug") + Arg::new("debug") .help("turn on debugging information") .short('d'), ) .args(&[ - Arg::with_name("config") + Arg::new("config") .help("sets the config file to use") .setting(ArgSettings::TakesValue) .short('c') .long("config"), - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .index(1) .setting(ArgSettings::Required), @@ -68,19 +68,19 @@ fn app_example4<'b, 'c>() -> App<'b, 'c> { .version("1.0") .author("Kevin K. ") .arg( - Arg::with_name("debug") + Arg::new("debug") .help("turn on debugging information") .short('d') .long("debug"), ) .arg( - Arg::with_name("config") + Arg::new("config") .help("sets the config file to use") .short('c') .long("config"), ) .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .index(1) .setting(ArgSettings::Required), @@ -89,7 +89,7 @@ fn app_example4<'b, 'c>() -> App<'b, 'c> { fn app_example5<'b, 'c>() -> App<'b, 'c> { App::new("MyApp").arg( - Arg::with_name("awesome") + Arg::new("awesome") .help("turns up the awesome") .short('a') .long("awesome") @@ -102,7 +102,7 @@ fn app_example5<'b, 'c>() -> App<'b, 'c> { fn app_example6<'b, 'c>() -> App<'b, 'c> { App::new("MyApp") .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .index(1) .requires("config") @@ -110,7 +110,7 @@ fn app_example6<'b, 'c>() -> App<'b, 'c> { .setting(ArgSettings::Required), ) .arg( - Arg::with_name("config") + Arg::new("config") .help("the config file to use") .index(2), ) @@ -118,10 +118,10 @@ fn app_example6<'b, 'c>() -> App<'b, 'c> { fn app_example7<'b, 'c>() -> App<'b, 'c> { App::new("MyApp") - .arg(Arg::with_name("config")) - .arg(Arg::with_name("output")) + .arg(Arg::new("config")) + .arg(Arg::new("output")) .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .settings(&[ ArgSettings::MultipleValues, @@ -137,10 +137,10 @@ fn app_example7<'b, 'c>() -> App<'b, 'c> { fn app_example8<'b, 'c>() -> App<'b, 'c> { App::new("MyApp") - .arg(Arg::with_name("config")) - .arg(Arg::with_name("output")) + .arg(Arg::new("config")) + .arg(Arg::new("output")) .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .settings(&[ ArgSettings::MultipleValues, @@ -156,7 +156,7 @@ fn app_example8<'b, 'c>() -> App<'b, 'c> { fn app_example10<'b, 'c>() -> App<'b, 'c> { App::new("myapp").about("does awesome things").arg( - Arg::with_name("CONFIG") + Arg::new("CONFIG") .help("The config file to use (default is \"config.json\")") .short('c') .setting(ArgSettings::TakesValue), diff --git a/benches/05_ripgrep.rs b/benches/05_ripgrep.rs index 4fa67ce3..48e32bf9 100644 --- a/benches/05_ripgrep.rs +++ b/benches/05_ripgrep.rs @@ -279,7 +279,7 @@ fn app(next_line_help: bool, doc: F) -> App<'static, 'static> where F: Fn(&'static str) -> &'static str, { - let arg = |name| Arg::with_name(name).help(doc(name)); + let arg = |name| Arg::new(name).help(doc(name)); let flag = |name| arg(name).long(name); App::new("ripgrep") diff --git a/benches/06_rustup.rs b/benches/06_rustup.rs index c18473d8..987895dc 100644 --- a/benches/06_rustup.rs +++ b/benches/06_rustup.rs @@ -31,7 +31,7 @@ pub fn build_cli() -> App<'static, 'static> { .setting(AppSettings::DeriveDisplayOrder) // .setting(AppSettings::SubcommandRequiredElseHelp) .arg( - Arg::with_name("verbose") + Arg::new("verbose") .help("Enable verbose output") .short('v') .long("verbose"), @@ -46,15 +46,15 @@ pub fn build_cli() -> App<'static, 'static> { .about("Update Rust toolchains") .after_help(TOOLCHAIN_INSTALL_HELP) .setting(AppSettings::Hidden) // synonym for 'toolchain install' - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("update") .about("Update Rust toolchains") .after_help(UPDATE_HELP) - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)) + .arg(Arg::new("toolchain").setting(ArgSettings::Required)) .arg( - Arg::with_name("no-self-update") + Arg::new("no-self-update") .help("Don't perform self update when running the `rustup` command") .long("no-self-update") .setting(ArgSettings::Hidden), @@ -64,7 +64,7 @@ pub fn build_cli() -> App<'static, 'static> { App::new("default") .about("Set the default toolchain") .after_help(DEFAULT_HELP) - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("toolchain") @@ -76,33 +76,33 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("install") .about("Install or update a given toolchain") - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("uninstall") .about("Uninstall a toolchain") - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("link") .about("Create a custom toolchain by symlinking to a directory") - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)) - .arg(Arg::with_name("path").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)) + .arg(Arg::new("path").setting(ArgSettings::Required)), ) .subcommand( App::new("update") .setting(AppSettings::Hidden) // synonym for 'install' - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("add") .setting(AppSettings::Hidden) // synonym for 'install' - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("remove") .setting(AppSettings::Hidden) // synonym for 'uninstall' - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ), ) .subcommand( @@ -115,7 +115,7 @@ pub fn build_cli() -> App<'static, 'static> { App::new("list") .about("List installed and available targets") .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -123,9 +123,9 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("add") .about("Add a target to a Rust toolchain") - .arg(Arg::with_name("target").setting(ArgSettings::Required)) + .arg(Arg::new("target").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -133,9 +133,9 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("remove") .about("Remove a target from a Rust toolchain") - .arg(Arg::with_name("target").setting(ArgSettings::Required)) + .arg(Arg::new("target").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -143,9 +143,9 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("install") .setting(AppSettings::Hidden) // synonym for 'add' - .arg(Arg::with_name("target").setting(ArgSettings::Required)) + .arg(Arg::new("target").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -153,9 +153,9 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("uninstall") .setting(AppSettings::Hidden) // synonym for 'remove' - .arg(Arg::with_name("target").setting(ArgSettings::Required)) + .arg(Arg::new("target").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -171,7 +171,7 @@ pub fn build_cli() -> App<'static, 'static> { App::new("list") .about("List installed and available components") .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -179,14 +179,14 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("add") .about("Add a component to a Rust toolchain") - .arg(Arg::with_name("component").setting(ArgSettings::Required)) + .arg(Arg::new("component").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ) .arg( - Arg::with_name("target") + Arg::new("target") .long("target") .setting(ArgSettings::TakesValue), ), @@ -194,14 +194,14 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("remove") .about("Remove a component from a Rust toolchain") - .arg(Arg::with_name("component").setting(ArgSettings::Required)) + .arg(Arg::new("component").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ) .arg( - Arg::with_name("target") + Arg::new("target") .long("target") .setting(ArgSettings::TakesValue), ), @@ -218,20 +218,20 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("set") .about("Set the override toolchain for a directory") - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("unset") .about("Remove the override toolchain for a directory") .after_help(OVERRIDE_UNSET_HELP) .arg( - Arg::with_name("path") + Arg::new("path") .long("path") .setting(ArgSettings::TakesValue) .help("Path to the directory"), ) .arg( - Arg::with_name("nonexistent") + Arg::new("nonexistent") .long("nonexistent") .help("Remove override toolchain for all nonexistent directories"), ), @@ -239,19 +239,19 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("add") .setting(AppSettings::Hidden) // synonym for 'set' - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)), + .arg(Arg::new("toolchain").setting(ArgSettings::Required)), ) .subcommand( App::new("remove") .setting(AppSettings::Hidden) // synonym for 'unset' .about("Remove the override toolchain for a directory") .arg( - Arg::with_name("path") + Arg::new("path") .long("path") .setting(ArgSettings::TakesValue), ) .arg( - Arg::with_name("nonexistent") + Arg::new("nonexistent") .long("nonexistent") .help("Remove override toolchain for all nonexistent directories"), ), @@ -262,8 +262,8 @@ pub fn build_cli() -> App<'static, 'static> { .about("Run a command with an environment configured for a given toolchain") .after_help(RUN_HELP) .setting(AppSettings::TrailingVarArg) - .arg(Arg::with_name("toolchain").setting(ArgSettings::Required)) - .arg(Arg::with_name("command").settings(&[ + .arg(Arg::new("toolchain").setting(ArgSettings::Required)) + .arg(Arg::new("command").settings(&[ ArgSettings::Required, ArgSettings::MultipleValues, ArgSettings::MultipleOccurrences, @@ -272,19 +272,19 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("which") .about("Display which binary will be run for a given command") - .arg(Arg::with_name("command").setting(ArgSettings::Required)), + .arg(Arg::new("command").setting(ArgSettings::Required)), ) .subcommand( App::new("doc") .about("Open the documentation for the current toolchain") .after_help(DOC_HELP) .arg( - Arg::with_name("book") + Arg::new("book") .long("book") .help("The Rust Programming Language book"), ) .arg( - Arg::with_name("std") + Arg::new("std") .long("std") .help("Standard library API documentation"), ) @@ -293,9 +293,9 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("man") .about("View the man page for a given command") - .arg(Arg::with_name("command").setting(ArgSettings::Required)) + .arg(Arg::new("command").setting(ArgSettings::Required)) .arg( - Arg::with_name("toolchain") + Arg::new("toolchain") .long("toolchain") .setting(ArgSettings::TakesValue), ), @@ -309,7 +309,7 @@ pub fn build_cli() -> App<'static, 'static> { .subcommand( App::new("uninstall") .about("Uninstall rustup.") - .arg(Arg::with_name("no-prompt").short('y')), + .arg(Arg::new("no-prompt").short('y')), ) .subcommand(App::new("upgrade-data").about("Upgrade the internal data format.")), ) @@ -327,7 +327,7 @@ pub fn build_cli() -> App<'static, 'static> { App::new("set").about("Alter rustup settings").subcommand( App::new("default-host") .about("The triple used to identify toolchains when not specified") - .arg(Arg::with_name("host_triple").setting(ArgSettings::Required)), + .arg(Arg::new("host_triple").setting(ArgSettings::Required)), ), ) } diff --git a/examples/01b_quick_example.rs b/examples/01b_quick_example.rs index 05796e5a..84f0dce9 100644 --- a/examples/01b_quick_example.rs +++ b/examples/01b_quick_example.rs @@ -8,7 +8,7 @@ fn main() { // // The example below is functionally identical to the 01a_quick_example.rs and 01c_quick_example.rs // - // *NOTE:* You can actually achieve the best of both worlds by using Arg::from() (instead of Arg::with_name()) + // *NOTE:* You can actually achieve the best of both worlds by using Arg::from() (instead of Arg::new()) // and *then* setting any additional properties. // // Create an application with 5 possible arguments (2 auto generated) and 2 subcommands (1 auto generated) @@ -38,7 +38,7 @@ fn main() { .author("Kevin K. ") .about("Does awesome things") .arg( - Arg::with_name("config") + Arg::new("config") .short('c') .long("config") .value_name("FILE") @@ -46,12 +46,12 @@ fn main() { .takes_value(true), ) .arg( - Arg::with_name("output") + Arg::new("output") .help("Sets an optional output file") .index(1), ) .arg( - Arg::with_name("debug") + Arg::new("debug") .short('d') .multiple(true) .help("Turn debugging information on"), @@ -59,7 +59,7 @@ fn main() { .subcommand( App::new("test") .about("does testing things") - .arg(Arg::with_name("list").short('l').help("lists test values")), + .arg(Arg::new("list").short('l').help("lists test values")), ) .get_matches(); diff --git a/examples/03_args.rs b/examples/03_args.rs index e0274cd3..682b58e3 100644 --- a/examples/03_args.rs +++ b/examples/03_args.rs @@ -29,27 +29,27 @@ fn main() { // All application settings go here... // A simple "Flag" argument example (i.e. "-d") using the builder pattern .arg( - Arg::with_name("debug") + Arg::new("debug") .help("turn on debugging information") .short('d'), ) // Two arguments, one "Option" argument (i.e. one that takes a value) such // as "-c some", and one positional argument (i.e. "myapp some_file") .args(&[ - Arg::with_name("config") + Arg::new("config") .help("sets the config file to use") .takes_value(true) .short('c') .long("config"), - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .index(1) .required(true), ]) // *Note* the following two examples are convenience methods, if you wish - // to still get the full configurability of Arg::with_name() and the readability + // to still get the full configurability of Arg::new() and the readability // of arg(), you can instantiate a new Arg with Arg::from() and - // still be able to set all the additional properties, just like Arg::with_name() + // still be able to set all the additional properties, just like Arg::new() // // // One "Flag" using a usage string diff --git a/examples/04_using_matches.rs b/examples/04_using_matches.rs index af2e7d04..78c6f7cb 100644 --- a/examples/04_using_matches.rs +++ b/examples/04_using_matches.rs @@ -21,19 +21,19 @@ fn main() { .version("1.0") .author("Kevin K. ") .arg( - Arg::with_name("debug") + Arg::new("debug") .help("turn on debugging information") .short('d') .long("debug"), ) .arg( - Arg::with_name("config") + Arg::new("config") .help("sets the config file to use") .short('c') .long("config"), ) .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .index(1) .required(true), diff --git a/examples/05_flag_args.rs b/examples/05_flag_args.rs index 190c81ce..5c488aa6 100644 --- a/examples/05_flag_args.rs +++ b/examples/05_flag_args.rs @@ -16,7 +16,7 @@ fn main() { // that you DO NOT need to set each of these for every flag, only the ones // you want for your individual case. .arg( - Arg::with_name("awesome") + Arg::new("awesome") .help("turns up the awesome") // Displayed when showing help info .short('a') // Trigger this arg with "-a" .long("awesome") // Trigger this arg with "--awesome" diff --git a/examples/06_positional_args.rs b/examples/06_positional_args.rs index 799c7612..25dd8391 100644 --- a/examples/06_positional_args.rs +++ b/examples/06_positional_args.rs @@ -14,7 +14,7 @@ fn main() { // mind that you DO NOT need to set each of these for every flag, only the // ones that apply to your individual case. .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") // Displayed when showing help info .index(1) // Set the order in which the user must // specify this argument (Starts at 1) @@ -30,7 +30,7 @@ fn main() { // required arguments ) .arg( - Arg::with_name("config") + Arg::new("config") .help("the config file to use") .index(2), ) // Note, we do not need to specify required(true) diff --git a/examples/07_option_args.rs b/examples/07_option_args.rs index 27ac0cbc..a856f312 100644 --- a/examples/07_option_args.rs +++ b/examples/07_option_args.rs @@ -16,7 +16,7 @@ fn main() { // NOTE: You DO NOT need to specify each setting, only those which apply // to your particular case. .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") // Displayed when showing help info .takes_value(true) // MUST be set to true in order to be an "option" argument .short('i') // This argument is triggered with "-i" diff --git a/examples/08_subcommands.rs b/examples/08_subcommands.rs index dc584edc..deda7b15 100644 --- a/examples/08_subcommands.rs +++ b/examples/08_subcommands.rs @@ -29,7 +29,7 @@ fn main() { .version("0.1") // Subcommands can have independent version .author("Kevin K.") // And authors .arg( - Arg::with_name("input") // And their own arguments + Arg::new("input") // And their own arguments .help("the file to add") .index(1) .required(true), diff --git a/examples/10_default_values.rs b/examples/10_default_values.rs index 16b5722e..fe71eb90 100644 --- a/examples/10_default_values.rs +++ b/examples/10_default_values.rs @@ -12,7 +12,7 @@ fn main() { let matches = App::new("myapp") .about("does awesome things") .arg( - Arg::with_name("INPUT") + Arg::new("INPUT") .help("The input file to use") // Note, we don't need to specify // anything like, "Defaults to..." // because clap will automatically @@ -23,7 +23,7 @@ fn main() { ) // Next we'll use the Option::unwrap_or method on this "CONFIG" option .arg( - Arg::with_name("CONFIG") + Arg::new("CONFIG") // Note that we have to manaully include some verbage to the user // telling them what the default will be. .help("The config file to use (default is \"config.json\")") diff --git a/examples/11_only_specific_values.rs b/examples/11_only_specific_values.rs index 73c6cee3..9d35e1df 100644 --- a/examples/11_only_specific_values.rs +++ b/examples/11_only_specific_values.rs @@ -15,7 +15,7 @@ fn main() { let matches = App::new("myapp") .about("does awesome things") .arg( - Arg::with_name("MODE") + Arg::new("MODE") .help("What mode to run the program in") .index(1) .possible_values(&["fast", "slow"]) diff --git a/examples/14_groups.rs b/examples/14_groups.rs index fe56d3b3..54382fe4 100644 --- a/examples/14_groups.rs +++ b/examples/14_groups.rs @@ -45,7 +45,7 @@ fn main() { // Now let's assume we have a -c [config] argument which requires one of // (but **not** both) the "input" arguments .arg( - Arg::with_name("config") + Arg::new("config") .short('c') .takes_value(true) .requires("input"), diff --git a/examples/15_custom_validator.rs b/examples/15_custom_validator.rs index d470b168..38104a75 100644 --- a/examples/15_custom_validator.rs +++ b/examples/15_custom_validator.rs @@ -10,7 +10,7 @@ fn main() { let matches = App::new("myapp") // Application logic goes here... .arg( - Arg::with_name("input") + Arg::new("input") .help("the input file to use") .index(1) .required(true) diff --git a/examples/20_subcommands.rs b/examples/20_subcommands.rs index b0d4b562..b8701fd4 100644 --- a/examples/20_subcommands.rs +++ b/examples/20_subcommands.rs @@ -50,7 +50,7 @@ fn main() { .author("Me") .subcommand( App::new("clone").about("clones repos").arg( - Arg::with_name("repo") + Arg::new("repo") .help("The repo to clone") .required(true), ), @@ -64,7 +64,7 @@ fn main() { // which in turn have their own subcommands .about("pushes remote things") .arg( - Arg::with_name("repo") + Arg::new("repo") .required(true) .help("The remote repo to push things to"), ), @@ -78,7 +78,7 @@ fn main() { .version("v2.0 (I'm versioned differently") // or different version from their parents .setting(AppSettings::ArgRequiredElseHelp) // They can even have different settings .arg( - Arg::with_name("stuff") + Arg::new("stuff") .long("stuff") .help("Stuff to add") .takes_value(true) diff --git a/examples/21_aliases.rs b/examples/21_aliases.rs index 1fd4b724..5bc77349 100644 --- a/examples/21_aliases.rs +++ b/examples/21_aliases.rs @@ -11,7 +11,7 @@ fn main() { .version("0.1") .author("Kevin K.") .arg( - Arg::with_name("input") + Arg::new("input") .help("the file to add") .index(1) .required(true), diff --git a/examples/22_stop_parsing_with_--.rs b/examples/22_stop_parsing_with_--.rs index bb0e4fa1..af1114d8 100644 --- a/examples/22_stop_parsing_with_--.rs +++ b/examples/22_stop_parsing_with_--.rs @@ -5,9 +5,9 @@ use clap::{App, Arg}; /// myprog -f -p=bob -- sloppy slop slop fn main() { let matches = App::new("myprog") - .arg(Arg::with_name("eff").short('f')) - .arg(Arg::with_name("pea").short('p').takes_value(true)) - .arg(Arg::with_name("slop").multiple(true).last(true)) + .arg(Arg::new("eff").short('f')) + .arg(Arg::new("pea").short('p').takes_value(true)) + .arg(Arg::new("slop").multiple(true).last(true)) .get_matches(); println!("-f used: {:?}", matches.is_present("eff")); diff --git a/tests/app_settings.rs b/tests/app_settings.rs index 0c963ce3..9e97af47 100644 --- a/tests/app_settings.rs +++ b/tests/app_settings.rs @@ -77,7 +77,7 @@ OPTIONS: fn sub_command_negate_required() { App::new("sub_command_negate") .setting(AppSettings::SubcommandsNegateReqs) - .arg(Arg::with_name("test").required(true).index(1)) + .arg(Arg::new("test").required(true).index(1)) .subcommand(App::new("sub1")) .get_matches_from(vec!["myprog", "sub1"]); } @@ -96,7 +96,7 @@ fn global_version() { fn sub_command_negate_required_2() { let result = App::new("sub_command_negate") .setting(AppSettings::SubcommandsNegateReqs) - .arg(Arg::with_name("test").required(true).index(1)) + .arg(Arg::new("test").required(true).index(1)) .subcommand(App::new("sub1")) .try_get_matches_from(vec![""]); assert!(result.is_err()); @@ -119,7 +119,7 @@ fn sub_command_required() { fn arg_required_else_help() { let result = App::new("arg_required") .setting(AppSettings::ArgRequiredElseHelp) - .arg(Arg::with_name("test").index(1)) + .arg(Arg::new("test").index(1)) .try_get_matches_from(vec![""]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -130,7 +130,7 @@ fn arg_required_else_help() { fn arg_required_else_help_over_reqs() { let result = App::new("arg_required") .setting(AppSettings::ArgRequiredElseHelp) - .arg(Arg::with_name("test").index(1).required(true)) + .arg(Arg::new("test").index(1).required(true)) .try_get_matches_from(vec![""]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -165,7 +165,7 @@ fn infer_subcommands_fail_no_args() { fn infer_subcommands_fail_with_args() { let m = App::new("prog") .setting(AppSettings::InferSubcommands) - .arg(Arg::with_name("some")) + .arg(Arg::new("some")) .subcommand(App::new("test")) .subcommand(App::new("temp")) .try_get_matches_from(vec!["prog", "t"]); @@ -177,7 +177,7 @@ fn infer_subcommands_fail_with_args() { fn infer_subcommands_fail_with_args2() { let m = App::new("prog") .setting(AppSettings::InferSubcommands) - .arg(Arg::with_name("some")) + .arg(Arg::new("some")) .subcommand(App::new("test")) .subcommand(App::new("temp")) .try_get_matches_from(vec!["prog", "te"]); @@ -232,7 +232,7 @@ fn infer_subcommands_fail_suggestions() { fn no_bin_name() { let result = App::new("arg_required") .setting(AppSettings::NoBinaryName) - .arg(Arg::with_name("test").required(true).index(1)) + .arg(Arg::new("test").required(true).index(1)) .try_get_matches_from(vec!["testing"]); assert!(result.is_ok()); let matches = result.unwrap(); @@ -416,8 +416,8 @@ fn delim_values_trailingvararg_with_delim() { fn leading_hyphen_short() { let res = App::new("leadhy") .setting(AppSettings::AllowLeadingHyphen) - .arg(Arg::with_name("some")) - .arg(Arg::with_name("other").short('o')) + .arg(Arg::new("some")) + .arg(Arg::new("other").short('o')) .try_get_matches_from(vec!["", "-bar", "-o"]); assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind); let m = res.unwrap(); @@ -430,8 +430,8 @@ fn leading_hyphen_short() { fn leading_hyphen_long() { let res = App::new("leadhy") .setting(AppSettings::AllowLeadingHyphen) - .arg(Arg::with_name("some")) - .arg(Arg::with_name("other").short('o')) + .arg(Arg::new("some")) + .arg(Arg::new("other").short('o')) .try_get_matches_from(vec!["", "--bar", "-o"]); assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind); let m = res.unwrap(); @@ -444,8 +444,8 @@ fn leading_hyphen_long() { fn leading_hyphen_opt() { let res = App::new("leadhy") .setting(AppSettings::AllowLeadingHyphen) - .arg(Arg::with_name("some").takes_value(true).long("opt")) - .arg(Arg::with_name("other").short('o')) + .arg(Arg::new("some").takes_value(true).long("opt")) + .arg(Arg::new("other").short('o')) .try_get_matches_from(vec!["", "--opt", "--bar", "-o"]); assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind); let m = res.unwrap(); @@ -458,8 +458,8 @@ fn leading_hyphen_opt() { fn allow_negative_numbers() { let res = App::new("negnum") .setting(AppSettings::AllowNegativeNumbers) - .arg(Arg::with_name("panum")) - .arg(Arg::with_name("onum").short('o').takes_value(true)) + .arg(Arg::new("panum")) + .arg(Arg::new("onum").short('o').takes_value(true)) .try_get_matches_from(vec!["negnum", "-20", "-o", "-1.2"]); assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind); let m = res.unwrap(); @@ -471,8 +471,8 @@ fn allow_negative_numbers() { fn allow_negative_numbers_fail() { let res = App::new("negnum") .setting(AppSettings::AllowNegativeNumbers) - .arg(Arg::with_name("panum")) - .arg(Arg::with_name("onum").short('o').takes_value(true)) + .arg(Arg::new("panum")) + .arg(Arg::new("onum").short('o').takes_value(true)) .try_get_matches_from(vec!["negnum", "--foo", "-o", "-1.2"]); assert!(res.is_err()); assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument) @@ -536,9 +536,9 @@ fn dont_collapse_args() { .version("v1.4.8") .setting(AppSettings::DontCollapseArgsInUsage) .args(&[ - Arg::with_name("arg1").help("some"), - Arg::with_name("arg2").help("some"), - Arg::with_name("arg3").help("some"), + Arg::new("arg1").help("some"), + Arg::new("arg2").help("some"), + Arg::new("arg3").help("some"), ]); assert!(test::compare_output( app, @@ -551,7 +551,7 @@ fn dont_collapse_args() { #[test] fn require_eq() { let app = App::new("clap-test").version("v1.4.8").arg( - Arg::with_name("opt") + Arg::new("opt") .long("opt") .short('o') .required(true) diff --git a/tests/arg_aliases.rs b/tests/arg_aliases.rs index 3f724180..1bce6ce4 100644 --- a/tests/arg_aliases.rs +++ b/tests/arg_aliases.rs @@ -37,7 +37,7 @@ OPTIONS: fn single_alias_of_option() { let a = App::new("single_alias") .arg( - Arg::with_name("alias") + Arg::new("alias") .long("alias") .takes_value(true) .help("single alias") @@ -53,7 +53,7 @@ fn single_alias_of_option() { #[test] fn multiple_aliases_of_option() { let a = App::new("multiple_aliases").arg( - Arg::with_name("aliases") + Arg::new("aliases") .long("aliases") .takes_value(true) .help("multiple aliases") @@ -96,7 +96,7 @@ fn multiple_aliases_of_option() { #[test] fn single_alias_of_flag() { let a = App::new("test") - .arg(Arg::with_name("flag").long("flag").alias("alias")) + .arg(Arg::new("flag").long("flag").alias("alias")) .try_get_matches_from(vec!["", "--alias"]); assert!(a.is_ok()); let a = a.unwrap(); @@ -105,7 +105,7 @@ fn single_alias_of_flag() { #[test] fn multiple_aliases_of_flag() { - let a = App::new("test").arg(Arg::with_name("flag").long("flag").aliases(&[ + let a = App::new("test").arg(Arg::new("flag").long("flag").aliases(&[ "invisible", "set", "of", @@ -140,7 +140,7 @@ fn alias_on_a_subcommand_option() { let m = App::new("test") .subcommand( App::new("some").arg( - Arg::with_name("test") + Arg::new("test") .short('t') .long("test") .takes_value(true) @@ -149,7 +149,7 @@ fn alias_on_a_subcommand_option() { ), ) .arg( - Arg::with_name("other") + Arg::new("other") .long("other") .aliases(&vec!["o1", "o2", "o3"]), ) @@ -168,7 +168,7 @@ fn invisible_arg_aliases_help_output() { .about("Some help") .version("1.2") .arg( - Arg::with_name("opt") + Arg::new("opt") .long("opt") .short('o') .takes_value(true) @@ -191,7 +191,7 @@ fn visible_arg_aliases_help_output() { .about("Some help") .version("1.2") .arg( - Arg::with_name("opt") + Arg::new("opt") .long("opt") .short('o') .takes_value(true) @@ -199,7 +199,7 @@ fn visible_arg_aliases_help_output() { .visible_alias("visible"), ) .arg( - Arg::with_name("flg") + Arg::new("flg") .long("flag") .short('f') .visible_aliases(&["v_flg", "flag2", "flg3"]), diff --git a/tests/borrowed.rs b/tests/borrowed.rs index 8a5ff5bb..3aa8f61a 100644 --- a/tests/borrowed.rs +++ b/tests/borrowed.rs @@ -7,16 +7,16 @@ include!("../clap-test.rs"); #[test] fn borrowed_args() { - let arg = Arg::with_name("some") + let arg = Arg::new("some") .short('s') .long("some") .help("other help"); - let arg2 = Arg::with_name("some2") + let arg2 = Arg::new("some2") .short('S') .long("some-thing") .help("other help"); let result = App::new("sub_command_negate") - .arg(Arg::with_name("test").index(1)) + .arg(Arg::new("test").index(1)) .arg(&arg) .arg(&arg2) .subcommand(App::new("sub1").arg(&arg)) diff --git a/tests/default_vals.rs b/tests/default_vals.rs index d1ffad62..e4f44e8e 100644 --- a/tests/default_vals.rs +++ b/tests/default_vals.rs @@ -390,20 +390,20 @@ fn conditional_reqs_fail() { .author("F0x06") .about("Arg test") .arg( - Arg::with_name("target") + Arg::new("target") .takes_value(true) .default_value("file") .possible_values(&["file", "stdout"]) .long("target"), ) .arg( - Arg::with_name("input") + Arg::new("input") .takes_value(true) .required(true) .long("input"), ) .arg( - Arg::with_name("output") + Arg::new("output") .takes_value(true) .required_if("target", "file") .long("output"), @@ -421,20 +421,20 @@ fn conditional_reqs_pass() { .author("F0x06") .about("Arg test") .arg( - Arg::with_name("target") + Arg::new("target") .takes_value(true) .default_value("file") .possible_values(&["file", "stdout"]) .long("target"), ) .arg( - Arg::with_name("input") + Arg::new("input") .takes_value(true) .required(true) .long("input"), ) .arg( - Arg::with_name("output") + Arg::new("output") .takes_value(true) .required_if("target", "file") .long("output"), @@ -451,7 +451,7 @@ fn conditional_reqs_pass() { fn issue_1050_num_vals_and_defaults() { let res = App::new("hello") .arg( - Arg::with_name("exit-code") + Arg::new("exit-code") .long("exit-code") .required(true) .takes_value(true) diff --git a/tests/delimiters.rs b/tests/delimiters.rs index b5d193cb..5eb3144b 100644 --- a/tests/delimiters.rs +++ b/tests/delimiters.rs @@ -6,7 +6,7 @@ use clap::{App, Arg, ArgSettings}; fn opt_default_no_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .setting(ArgSettings::TakesValue), ) @@ -24,7 +24,7 @@ fn opt_default_no_delim() { fn opt_eq_no_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .setting(ArgSettings::TakesValue), ) @@ -42,7 +42,7 @@ fn opt_eq_no_delim() { fn opt_s_eq_no_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .setting(ArgSettings::TakesValue), ) @@ -60,7 +60,7 @@ fn opt_s_eq_no_delim() { fn opt_s_default_no_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .setting(ArgSettings::TakesValue), ) @@ -78,7 +78,7 @@ fn opt_s_default_no_delim() { fn opt_s_no_space_no_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .setting(ArgSettings::TakesValue), ) @@ -96,7 +96,7 @@ fn opt_s_no_space_no_delim() { fn opt_s_no_space_mult_no_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .setting(ArgSettings::MultipleValues), ) @@ -114,7 +114,7 @@ fn opt_s_no_space_mult_no_delim() { fn opt_eq_mult_def_delim() { let m = App::new("no_delim") .arg( - Arg::with_name("option") + Arg::new("option") .long("opt") .multiple(true) .use_delimiter(true) diff --git a/tests/derive_order.rs b/tests/derive_order.rs index f4c1fd5d..8a9e110b 100644 --- a/tests/derive_order.rs +++ b/tests/derive_order.rs @@ -120,13 +120,13 @@ OPTIONS: #[test] fn no_derive_order() { let app = App::new("test").version("1.2").args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -146,13 +146,13 @@ fn derive_order() { .setting(AppSettings::DeriveDisplayOrder) .version("1.2") .args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -172,13 +172,13 @@ fn unified_help() { .setting(AppSettings::UnifiedHelpMessage) .version("1.2") .args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -199,13 +199,13 @@ fn unified_help_and_derive_order() { .setting(AppSettings::UnifiedHelpMessage) .version("1.2") .args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -226,13 +226,13 @@ fn derive_order_subcommand_propagate() { .version("1.2") .subcommand( App::new("sub").version("1.2").args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -253,13 +253,13 @@ fn unified_help_subcommand_propagate() { .global_setting(AppSettings::UnifiedHelpMessage) .subcommand( App::new("sub").version("1.2").args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -281,13 +281,13 @@ fn unified_help_and_derive_order_subcommand_propagate() { .global_setting(AppSettings::UnifiedHelpMessage) .subcommand( App::new("sub").version("1.2").args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a").long("flag_a").help("second flag"), - Arg::with_name("option_a") + Arg::new("flag_a").long("flag_a").help("second flag"), + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), @@ -309,16 +309,16 @@ fn unified_help_and_derive_order_subcommand_propagate_with_explicit_display_orde .global_setting(AppSettings::UnifiedHelpMessage) .subcommand( App::new("sub").version("1.2").args(&[ - Arg::with_name("flag_b").long("flag_b").help("first flag"), - Arg::with_name("option_b") + Arg::new("flag_b").long("flag_b").help("first flag"), + Arg::new("option_b") .long("option_b") .takes_value(true) .help("first option"), - Arg::with_name("flag_a") + Arg::new("flag_a") .long("flag_a") .help("second flag") .display_order(0), - Arg::with_name("option_a") + Arg::new("option_a") .long("option_a") .takes_value(true) .help("second option"), diff --git a/tests/global_args.rs b/tests/global_args.rs index abbab91f..ea45922f 100644 --- a/tests/global_args.rs +++ b/tests/global_args.rs @@ -9,7 +9,7 @@ mod tests { fn get_app() -> App<'static, 'static> { App::new("myprog") .arg( - Arg::with_name("GLOBAL_ARG") + Arg::new("GLOBAL_ARG") .long("global-arg") .help("Specifies something needed by the subcommands") .global(true) @@ -17,7 +17,7 @@ mod tests { .default_value("default_value"), ) .arg( - Arg::with_name("GLOBAL_FLAG") + Arg::new("GLOBAL_FLAG") .long("global-flag") .help("Specifies something needed by the subcommands") .multiple(true) diff --git a/tests/help.rs b/tests/help.rs index e617ce8f..5aef410f 100644 --- a/tests/help.rs +++ b/tests/help.rs @@ -598,33 +598,33 @@ fn args_with_last_usage() { .version("0.1") .setting(AppSettings::TrailingVarArg) .arg( - Arg::with_name("verbose") + Arg::new("verbose") .help("Prints out more stuff.") .short('v') .long("verbose") .setting(ArgSettings::MultipleOccurrences), ) .arg( - Arg::with_name("timeout") + Arg::new("timeout") .help("Timeout in seconds.") .short('t') .long("timeout") .value_name("SECONDS"), ) .arg( - Arg::with_name("frequency") + Arg::new("frequency") .help("The sampling frequency.") .short('f') .long("frequency") .value_name("HERTZ"), ) .arg( - Arg::with_name("binary path") + Arg::new("binary path") .help("The path of the binary to be profiled. for a binary.") .value_name("BINFILE"), ) .arg( - Arg::with_name("pass through args") + Arg::new("pass through args") .help("Any arguments you wish to pass to the being profiled.") .settings(&[ ArgSettings::MultipleValues, @@ -748,7 +748,7 @@ fn complex_subcommand_help_output() { #[test] fn issue_626_unicode_cutoff() { let app = App::new("ctest").version("0.1").set_term_width(70).arg( - Arg::with_name("cafe") + Arg::new("cafe") .short('c') .long("cafe") .value_name("FILE") @@ -775,7 +775,7 @@ fn hide_possible_vals() { let app = App::new("ctest") .version("0.1") .arg( - Arg::with_name("pos") + Arg::new("pos") .short('p') .long("pos") .value_name("VAL") @@ -784,7 +784,7 @@ fn hide_possible_vals() { .takes_value(true), ) .arg( - Arg::with_name("cafe") + Arg::new("cafe") .short('c') .long("cafe") .value_name("FILE") @@ -806,7 +806,7 @@ fn issue_626_panic() { let app = App::new("ctest") .version("0.1") .set_term_width(52) - .arg(Arg::with_name("cafe") + .arg(Arg::new("cafe") .short('c') .long("cafe") .value_name("FILE") @@ -828,7 +828,7 @@ fn issue_626_variable_panic() { let _ = App::new("ctest") .version("0.1") .set_term_width(i) - .arg(Arg::with_name("cafe") + .arg(Arg::new("cafe") .short('c') .long("cafe") .value_name("FILE") @@ -856,7 +856,7 @@ fn wrapping_newline_chars() { let app = App::new("ctest") .version("0.1") .set_term_width(60) - .arg(Arg::with_name("mode").help( + .arg(Arg::new("mode").help( "x, max, maximum 20 characters, contains symbols.{n}\ l, long Copy-friendly, 14 characters, contains symbols.{n}\ m, med, medium Copy-friendly, 8 characters, contains symbols.{n}", @@ -872,7 +872,7 @@ fn wrapping_newline_chars() { #[test] fn old_newline_chars() { let app = App::new("ctest").version("0.1").arg( - Arg::with_name("mode") + Arg::new("mode") .short('m') .help("Some help with some wrapping{n}(Defaults to something)"), ); @@ -892,7 +892,7 @@ fn issue_688_hidden_pos_vals() { .version("0.1") .set_term_width(120) .setting(AppSettings::HidePossibleValuesInHelp) - .arg(Arg::with_name("filter") + .arg(Arg::new("filter") .help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \ images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]") .long("filter") @@ -903,7 +903,7 @@ fn issue_688_hidden_pos_vals() { let app2 = App::new("ctest") .version("0.1") .set_term_width(120) - .arg(Arg::with_name("filter") + .arg(Arg::new("filter") .help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \ images. The default is Linear (Bilinear).") .long("filter") @@ -914,7 +914,7 @@ fn issue_688_hidden_pos_vals() { let app3 = App::new("ctest") .version("0.1") .set_term_width(120) - .arg(Arg::with_name("filter") + .arg(Arg::new("filter") .help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \ images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]") .long("filter") @@ -928,24 +928,24 @@ fn issue_702_multiple_values() { .version("1.0") .author("foo") .about("bar") - .arg(Arg::with_name("arg1").help("some option")) - .arg(Arg::with_name("arg2").multiple(true).help("some option")) + .arg(Arg::new("arg1").help("some option")) + .arg(Arg::new("arg2").multiple(true).help("some option")) .arg( - Arg::with_name("some") + Arg::new("some") .help("some option") .short('s') .long("some") .takes_value(true), ) .arg( - Arg::with_name("other") + Arg::new("other") .help("some other option") .short('o') .long("other") .takes_value(true), ) .arg( - Arg::with_name("label") + Arg::new("label") .help("a label") .short('l') .long("label") @@ -964,7 +964,7 @@ fn long_about() { .long_about( "something really really long, with\nmultiple lines of text\nthat should be displayed", ) - .arg(Arg::with_name("arg1").help("some option")); + .arg(Arg::new("arg1").help("some option")); assert!(test::compare_output(app, "myapp --help", LONG_ABOUT, false)); } @@ -973,7 +973,7 @@ fn issue_760() { let app = App::new("ctest") .version("0.1") .arg( - Arg::with_name("option") + Arg::new("option") .help("tests options") .short('o') .long("option") @@ -982,7 +982,7 @@ fn issue_760() { .number_of_values(1), ) .arg( - Arg::with_name("opt") + Arg::new("opt") .help("tests options") .short('O') .long("opt") @@ -1033,7 +1033,7 @@ fn sc_negates_reqs() { .version("1.0") .setting(AppSettings::SubcommandsNegateReqs) .arg("-o, --opt 'tests options'") - .arg(Arg::with_name("PATH").help("help")) + .arg(Arg::new("PATH").help("help")) .subcommand(App::new("test")); assert!(test::compare_output( app, @@ -1049,7 +1049,7 @@ fn hidden_args() { .version("1.0") .arg("-f, --flag 'testing flags'") .arg("-o, --opt [FILE] 'tests options'") - .arg(Arg::with_name("pos").hidden(true)); + .arg(Arg::new("pos").hidden(true)); assert!(test::compare_output(app, "prog --help", HIDDEN_ARGS, false)); } @@ -1060,7 +1060,7 @@ fn args_negate_sc() { .setting(AppSettings::ArgsNegateSubcommands) .arg("-f, --flag 'testing flags'") .arg("-o, --opt [FILE] 'tests options'") - .arg(Arg::with_name("PATH").help("help")) + .arg(Arg::new("PATH").help("help")) .subcommand(App::new("test")); assert!(test::compare_output( app, @@ -1076,7 +1076,7 @@ fn issue_1046_hidden_scs() { .version("1.0") .arg("-f, --flag 'testing flags'") .arg("-o, --opt [FILE] 'tests options'") - .arg(Arg::with_name("PATH").help("some")) + .arg(Arg::new("PATH").help("some")) .subcommand(App::new("test").setting(AppSettings::Hidden)); assert!(test::compare_output( app, @@ -1122,10 +1122,10 @@ fn customize_version_and_help() { fn last_arg_mult_usage() { let app = App::new("last") .version("0.1") - .arg(Arg::with_name("TARGET").required(true).help("some")) - .arg(Arg::with_name("CORPUS").help("some")) + .arg(Arg::new("TARGET").required(true).help("some")) + .arg(Arg::new("CORPUS").help("some")) .arg( - Arg::with_name("ARGS") + Arg::new("ARGS") .multiple(true) .last(true) .help("some"), @@ -1137,10 +1137,10 @@ fn last_arg_mult_usage() { fn last_arg_mult_usage_req() { let app = App::new("last") .version("0.1") - .arg(Arg::with_name("TARGET").required(true).help("some")) - .arg(Arg::with_name("CORPUS").help("some")) + .arg(Arg::new("TARGET").required(true).help("some")) + .arg(Arg::new("CORPUS").help("some")) .arg( - Arg::with_name("ARGS") + Arg::new("ARGS") .multiple(true) .last(true) .required(true) @@ -1159,10 +1159,10 @@ fn last_arg_mult_usage_req_with_sc() { let app = App::new("last") .version("0.1") .setting(AppSettings::SubcommandsNegateReqs) - .arg(Arg::with_name("TARGET").required(true).help("some")) - .arg(Arg::with_name("CORPUS").help("some")) + .arg(Arg::new("TARGET").required(true).help("some")) + .arg(Arg::new("CORPUS").help("some")) .arg( - Arg::with_name("ARGS") + Arg::new("ARGS") .multiple(true) .last(true) .required(true) @@ -1182,10 +1182,10 @@ fn last_arg_mult_usage_with_sc() { let app = App::new("last") .version("0.1") .setting(AppSettings::ArgsNegateSubcommands) - .arg(Arg::with_name("TARGET").required(true).help("some")) - .arg(Arg::with_name("CORPUS").help("some")) + .arg(Arg::new("TARGET").required(true).help("some")) + .arg(Arg::new("CORPUS").help("some")) .arg( - Arg::with_name("ARGS") + Arg::new("ARGS") .multiple(true) .last(true) .help("some"), @@ -1197,7 +1197,7 @@ fn last_arg_mult_usage_with_sc() { #[test] fn hidden_default_val() { let app1 = App::new("default").version("0.1").set_term_width(120).arg( - Arg::with_name("argument") + Arg::new("argument") .help("Pass an argument to the program. [default: default-argument]") .long("arg") .default_value("default-argument") @@ -1211,7 +1211,7 @@ fn hidden_default_val() { )); let app2 = App::new("default").version("0.1").set_term_width(120).arg( - Arg::with_name("argument") + Arg::new("argument") .help("Pass an argument to the program.") .long("arg") .default_value("default-argument"), @@ -1302,7 +1302,7 @@ fn hide_env_vals() { let app = App::new("ctest") .version("0.1") .arg( - Arg::with_name("pos") + Arg::new("pos") .short('p') .long("pos") .value_name("VAL") @@ -1311,7 +1311,7 @@ fn hide_env_vals() { .takes_value(true), ) .arg( - Arg::with_name("cafe") + Arg::new("cafe") .short('c') .long("cafe") .value_name("FILE") @@ -1336,7 +1336,7 @@ fn show_env_vals() { let app = App::new("ctest") .version("0.1") .arg( - Arg::with_name("pos") + Arg::new("pos") .short('p') .long("pos") .value_name("VAL") @@ -1345,7 +1345,7 @@ fn show_env_vals() { .takes_value(true), ) .arg( - Arg::with_name("cafe") + Arg::new("cafe") .short('c') .long("cafe") .value_name("FILE") @@ -1375,7 +1375,7 @@ fn custom_headers_headers() { ) .help_heading("NETWORKING") .arg( - Arg::with_name("no-proxy") + Arg::new("no-proxy") .short('n') .long("no-proxy") .help("Do not use system proxy settings"), @@ -1423,7 +1423,7 @@ fn multiple_custom_help_headers() { ) .help_heading("NETWORKING") .arg( - Arg::with_name("no-proxy") + Arg::new("no-proxy") .short('n') .long("no-proxy") .help("Do not use system proxy settings"), @@ -1434,7 +1434,7 @@ fn multiple_custom_help_headers() { )) .stop_custom_headings() .arg( - Arg::with_name("speed") + Arg::new("speed") .long("speed") .short('s') .value_name("SPEED") diff --git a/tests/hidden_args.rs b/tests/hidden_args.rs index 35a3d90d..fdf59d99 100644 --- a/tests/hidden_args.rs +++ b/tests/hidden_args.rs @@ -30,7 +30,7 @@ fn hidden_args() { Arg::from("-f, --flag 'some flag'").hidden(true), Arg::from("-F, --flag2 'some other flag'"), Arg::from("--option [opt] 'some option'"), - Arg::with_name("DUMMY").hidden(true), + Arg::new("DUMMY").hidden(true), ]); assert!(test::compare_output(app, "test --help", HIDDEN_ARGS, false)); } @@ -75,12 +75,12 @@ fn hidden_short_args() { .author("Steve P.") .version("2.31.2") .args(&[ - Arg::with_name("cfg") + Arg::new("cfg") .short('c') .long("config") .hidden_short_help(true) .help("Some help text describing the --config arg"), - Arg::with_name("visible") + Arg::new("visible") .short('v') .long("visible") .help("This text should be visible"), @@ -102,12 +102,12 @@ fn hidden_short_args_long_help() { .author("Steve P.") .version("2.31.2") .args(&[ - Arg::with_name("cfg") + Arg::new("cfg") .short('c') .long("config") .hidden_short_help(true) .help("Some help text describing the --config arg"), - Arg::with_name("visible") + Arg::new("visible") .short('v') .long("visible") .help("This text should be visible"), @@ -145,12 +145,12 @@ fn hidden_long_args() { .author("Steve P.") .version("2.31.2") .args(&[ - Arg::with_name("cfg") + Arg::new("cfg") .short('c') .long("config") .hidden_long_help(true) .help("Some help text describing the --config arg"), - Arg::with_name("visible") + Arg::new("visible") .short('v') .long("visible") .help("This text should be visible"), @@ -184,12 +184,12 @@ fn hidden_long_args_short_help() { .author("Steve P.") .version("2.31.2") .args(&[ - Arg::with_name("cfg") + Arg::new("cfg") .short('c') .long("config") .hidden_long_help(true) .help("Some help text describing the --config arg"), - Arg::with_name("visible") + Arg::new("visible") .short('v') .long("visible") .help("This text should be visible"), diff --git a/tests/indices.rs b/tests/indices.rs index 60295295..06f42425 100644 --- a/tests/indices.rs +++ b/tests/indices.rs @@ -9,13 +9,13 @@ use clap::{App, Arg}; fn indices_mult_opts() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .takes_value(true) .multiple(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .takes_value(true) .multiple(true), @@ -36,13 +36,13 @@ fn indices_mult_opts() { fn index_mult_opts() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .takes_value(true) .multiple(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .takes_value(true) .multiple(true), @@ -56,8 +56,8 @@ fn index_mult_opts() { #[test] fn index_flag() { let m = App::new("ind") - .arg(Arg::with_name("exclude").short('e')) - .arg(Arg::with_name("include").short('i')) + .arg(Arg::new("exclude").short('e')) + .arg(Arg::new("include").short('i')) .get_matches_from(vec!["ind", "-e", "-i"]); assert_eq!(m.index_of("exclude"), Some(1)); @@ -68,12 +68,12 @@ fn index_flag() { fn index_flags() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .multiple_occurrences(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .multiple_occurrences(true), ) @@ -87,12 +87,12 @@ fn index_flags() { fn indices_mult_flags() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .multiple_occurrences(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .multiple_occurrences(true), ) @@ -112,12 +112,12 @@ fn indices_mult_flags() { fn indices_mult_flags_combined() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .multiple_occurrences(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .multiple_occurrences(true), ) @@ -137,16 +137,16 @@ fn indices_mult_flags_combined() { fn indices_mult_flags_opt_combined() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .multiple_occurrences(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .multiple_occurrences(true), ) - .arg(Arg::with_name("option").short('o').takes_value(true)) + .arg(Arg::new("option").short('o').takes_value(true)) .get_matches_from(vec!["ind", "-eieeio", "val"]); assert_eq!( @@ -164,16 +164,16 @@ fn indices_mult_flags_opt_combined() { fn indices_mult_flags_opt_combined_eq() { let m = App::new("ind") .arg( - Arg::with_name("exclude") + Arg::new("exclude") .short('e') .multiple_occurrences(true), ) .arg( - Arg::with_name("include") + Arg::new("include") .short('i') .multiple_occurrences(true), ) - .arg(Arg::with_name("option").short('o').takes_value(true)) + .arg(Arg::new("option").short('o').takes_value(true)) .get_matches_from(vec!["ind", "-eieeio=val"]); assert_eq!( @@ -191,7 +191,7 @@ fn indices_mult_flags_opt_combined_eq() { fn indices_mult_opt_value_delim_eq() { let m = App::new("myapp") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .takes_value(true) .use_delimiter(true) @@ -208,7 +208,7 @@ fn indices_mult_opt_value_delim_eq() { fn indices_mult_opt_value_no_delim_eq() { let m = App::new("myapp") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .takes_value(true) .multiple(true), @@ -221,12 +221,12 @@ fn indices_mult_opt_value_no_delim_eq() { fn indices_mult_opt_mult_flag() { let m = App::new("myapp") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .takes_value(true) .multiple_occurrences(true), ) - .arg(Arg::with_name("flag").short('f').multiple_occurrences(true)) + .arg(Arg::new("flag").short('f').multiple_occurrences(true)) .get_matches_from(vec!["myapp", "-o", "val1", "-f", "-o", "val2", "-f"]); assert_eq!(m.indices_of("option").unwrap().collect::>(), &[2, 5]); diff --git a/tests/multiple_values.rs b/tests/multiple_values.rs index aad11565..6c913f2b 100644 --- a/tests/multiple_values.rs +++ b/tests/multiple_values.rs @@ -6,7 +6,7 @@ use clap::{App, Arg, ErrorKind}; fn option_long() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .help("multiple options") .takes_value(true) @@ -31,7 +31,7 @@ fn option_long() { fn option_short() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -54,7 +54,7 @@ fn option_short() { fn option_mixed() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .short('o') .help("multiple options") @@ -80,7 +80,7 @@ fn option_mixed() { fn option_exact_exact() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -104,7 +104,7 @@ fn option_exact_exact() { fn option_exact_exact_not_mult() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -127,7 +127,7 @@ fn option_exact_exact_not_mult() { fn option_exact_exact_mult() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -153,7 +153,7 @@ fn option_exact_exact_mult() { fn option_exact_less() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -170,7 +170,7 @@ fn option_exact_less() { fn option_exact_more() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -189,7 +189,7 @@ fn option_exact_more() { fn option_min_exact() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -213,7 +213,7 @@ fn option_min_exact() { fn option_min_less() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -229,9 +229,9 @@ fn option_min_less() { #[test] fn option_short_min_more_mult_occurs() { let res = App::new("multiple_values") - .arg(Arg::with_name("arg").required(true)) + .arg(Arg::new("arg").required(true)) .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -258,9 +258,9 @@ fn option_short_min_more_mult_occurs() { #[test] fn option_short_min_more_single_occur() { let res = App::new("multiple_values") - .arg(Arg::with_name("arg").required(true)) + .arg(Arg::new("arg").required(true)) .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -286,7 +286,7 @@ fn option_short_min_more_single_occur() { fn option_max_exact() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -310,7 +310,7 @@ fn option_max_exact() { fn option_max_less() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -334,7 +334,7 @@ fn option_max_less() { fn option_max_more() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .takes_value(true) @@ -353,7 +353,7 @@ fn option_max_more() { fn positional() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .multiple(true), ) @@ -374,7 +374,7 @@ fn positional() { fn positional_exact_exact() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .number_of_values(3), ) @@ -395,7 +395,7 @@ fn positional_exact_exact() { fn positional_exact_less() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .number_of_values(3), ) @@ -409,7 +409,7 @@ fn positional_exact_less() { fn positional_exact_more() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .number_of_values(3), ) @@ -423,7 +423,7 @@ fn positional_exact_more() { fn positional_min_exact() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .min_values(3), ) @@ -444,7 +444,7 @@ fn positional_min_exact() { fn positional_min_less() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .min_values(3), ) @@ -458,7 +458,7 @@ fn positional_min_less() { fn positional_min_more() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .min_values(3), ) @@ -479,7 +479,7 @@ fn positional_min_more() { fn positional_max_exact() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .max_values(3), ) @@ -500,7 +500,7 @@ fn positional_max_exact() { fn positional_max_less() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .max_values(3), ) @@ -521,7 +521,7 @@ fn positional_max_less() { fn positional_max_more() { let m = App::new("multiple_values") .arg( - Arg::with_name("pos") + Arg::new("pos") .help("multiple positionals") .max_values(3), ) @@ -535,7 +535,7 @@ fn positional_max_more() { fn sep_long_equals() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .use_delimiter(true) .help("multiple options") @@ -559,7 +559,7 @@ fn sep_long_equals() { fn sep_long_space() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .use_delimiter(true) .help("multiple options") @@ -583,7 +583,7 @@ fn sep_long_space() { fn sep_short_equals() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .use_delimiter(true) @@ -607,7 +607,7 @@ fn sep_short_equals() { fn sep_short_space() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .use_delimiter(true) @@ -631,7 +631,7 @@ fn sep_short_space() { fn sep_short_no_space() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .help("multiple options") .use_delimiter(true) @@ -655,7 +655,7 @@ fn sep_short_no_space() { fn sep_positional() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .help("multiple options") .use_delimiter(true) .multiple(true), @@ -677,7 +677,7 @@ fn sep_positional() { fn different_sep() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .help("multiple options") .takes_value(true) @@ -700,7 +700,7 @@ fn different_sep() { fn different_sep_positional() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .help("multiple options") .value_delimiter(";"), ) @@ -721,7 +721,7 @@ fn different_sep_positional() { fn no_sep() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .help("multiple options") .takes_value(true) @@ -741,7 +741,7 @@ fn no_sep() { fn no_sep_positional() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .help("multiple options") .use_delimiter(false), ) @@ -759,14 +759,14 @@ fn no_sep_positional() { fn req_delimiter_long() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .multiple(true) .use_delimiter(true) .require_delimiter(true) .takes_value(true), ) - .arg(Arg::with_name("args").multiple(true).index(1)) + .arg(Arg::new("args").multiple(true).index(1)) .try_get_matches_from(vec!["", "--option", "val1", "val2", "val3"]); assert!(m.is_ok()); @@ -788,14 +788,14 @@ fn req_delimiter_long() { fn req_delimiter_long_with_equal() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .multiple(true) .use_delimiter(true) .require_delimiter(true) .takes_value(true), ) - .arg(Arg::with_name("args").multiple(true).index(1)) + .arg(Arg::new("args").multiple(true).index(1)) .try_get_matches_from(vec!["", "--option=val1", "val2", "val3"]); assert!(m.is_ok()); @@ -817,14 +817,14 @@ fn req_delimiter_long_with_equal() { fn req_delimiter_short_with_space() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .multiple(true) .use_delimiter(true) .require_delimiter(true) .takes_value(true), ) - .arg(Arg::with_name("args").multiple(true).index(1)) + .arg(Arg::new("args").multiple(true).index(1)) .try_get_matches_from(vec!["", "-o", "val1", "val2", "val3"]); assert!(m.is_ok()); @@ -846,14 +846,14 @@ fn req_delimiter_short_with_space() { fn req_delimiter_short_with_no_space() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .multiple(true) .use_delimiter(true) .require_delimiter(true) .takes_value(true), ) - .arg(Arg::with_name("args").multiple(true).index(1)) + .arg(Arg::new("args").multiple(true).index(1)) .try_get_matches_from(vec!["", "-oval1", "val2", "val3"]); assert!(m.is_ok()); @@ -875,14 +875,14 @@ fn req_delimiter_short_with_no_space() { fn req_delimiter_short_with_equal() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .multiple(true) .use_delimiter(true) .require_delimiter(true) .takes_value(true), ) - .arg(Arg::with_name("args").multiple(true).index(1)) + .arg(Arg::new("args").multiple(true).index(1)) .try_get_matches_from(vec!["", "-o=val1", "val2", "val3"]); assert!(m.is_ok()); @@ -904,7 +904,7 @@ fn req_delimiter_short_with_equal() { fn req_delimiter_complex() { let m = App::new("multiple_values") .arg( - Arg::with_name("option") + Arg::new("option") .long("option") .short('o') .multiple(true) @@ -912,7 +912,7 @@ fn req_delimiter_complex() { .require_delimiter(true) .takes_value(true), ) - .arg(Arg::with_name("args").multiple(true).index(1)) + .arg(Arg::new("args").multiple(true).index(1)) .try_get_matches_from(vec![ "", "val1", @@ -968,12 +968,12 @@ fn req_delimiter_complex() { fn low_index_positional_not_required() { let _ = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .index(1) .required(true) .multiple(true), ) - .arg(Arg::with_name("target").index(2)) + .arg(Arg::new("target").index(2)) .try_get_matches_from(vec!["lip", "file1", "file2", "file3", "target"]); } @@ -982,13 +982,13 @@ fn low_index_positional_not_required() { fn low_index_positional_last_multiple_too() { let _ = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .index(1) .required(true) .multiple(true), ) .arg( - Arg::with_name("target") + Arg::new("target") .index(2) .required(true) .multiple(true), @@ -1001,13 +1001,13 @@ fn low_index_positional_last_multiple_too() { fn low_index_positional_too_far_back() { let _ = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .index(1) .required(true) .multiple(true), ) - .arg(Arg::with_name("target").required(true).index(2)) - .arg(Arg::with_name("target2").required(true).index(3)) + .arg(Arg::new("target").required(true).index(2)) + .arg(Arg::new("target2").required(true).index(3)) .try_get_matches_from(vec!["lip", "file1", "file2", "file3", "target"]); } @@ -1015,12 +1015,12 @@ fn low_index_positional_too_far_back() { fn low_index_positional() { let m = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .index(1) .required(true) .multiple(true), ) - .arg(Arg::with_name("target").index(2).required(true)) + .arg(Arg::new("target").index(2).required(true)) .try_get_matches_from(vec!["lip", "file1", "file2", "file3", "target"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind); @@ -1043,12 +1043,12 @@ fn low_index_positional_in_subcmd() { .subcommand( App::new("test") .arg( - Arg::with_name("files") + Arg::new("files") .index(1) .required(true) .multiple(true), ) - .arg(Arg::with_name("target").index(2).required(true)), + .arg(Arg::new("target").index(2).required(true)), ) .try_get_matches_from(vec!["lip", "test", "file1", "file2", "file3", "target"]); @@ -1071,13 +1071,13 @@ fn low_index_positional_in_subcmd() { fn low_index_positional_with_option() { let m = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .required(true) .index(1) .multiple(true), ) - .arg(Arg::with_name("target").index(2).required(true)) - .arg(Arg::with_name("opt").long("option").takes_value(true)) + .arg(Arg::new("target").index(2).required(true)) + .arg(Arg::new("opt").long("option").takes_value(true)) .try_get_matches_from(vec![ "lip", "file1", "file2", "file3", "target", "--option", "test", ]); @@ -1101,13 +1101,13 @@ fn low_index_positional_with_option() { fn low_index_positional_with_flag() { let m = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .index(1) .required(true) .multiple(true), ) - .arg(Arg::with_name("target").index(2).required(true)) - .arg(Arg::with_name("flg").long("flag")) + .arg(Arg::new("target").index(2).required(true)) + .arg(Arg::new("flg").long("flag")) .try_get_matches_from(vec!["lip", "file1", "file2", "file3", "target", "--flag"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind); @@ -1129,12 +1129,12 @@ fn low_index_positional_with_flag() { fn multiple_value_terminator_option() { let m = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .short('f') .value_terminator(";") .multiple(true), ) - .arg(Arg::with_name("other")) + .arg(Arg::new("other")) .try_get_matches_from(vec!["lip", "-f", "val1", "val2", ";", "otherval"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind); @@ -1154,13 +1154,13 @@ fn multiple_value_terminator_option() { fn multiple_value_terminator_option_other_arg() { let m = App::new("lip") .arg( - Arg::with_name("files") + Arg::new("files") .short('f') .value_terminator(";") .multiple(true), ) - .arg(Arg::with_name("other")) - .arg(Arg::with_name("flag").short('F')) + .arg(Arg::new("other")) + .arg(Arg::new("flag").short('F')) .try_get_matches_from(vec!["lip", "-f", "val1", "val2", "-F", "otherval"]); assert!(m.is_ok(), "{:?}", m.unwrap_err().kind); @@ -1180,12 +1180,12 @@ fn multiple_value_terminator_option_other_arg() { fn multiple_vals_with_hyphen() { let res = App::new("do") .arg( - Arg::with_name("cmds") + Arg::new("cmds") .multiple(true) .allow_hyphen_values(true) .value_terminator(";"), ) - .arg(Arg::with_name("location")) + .arg(Arg::new("location")) .try_get_matches_from(vec![ "do", "find", diff --git a/tests/opts.rs b/tests/opts.rs index 0fcc5855..a514227a 100644 --- a/tests/opts.rs +++ b/tests/opts.rs @@ -19,7 +19,7 @@ For more information try --help"; fn require_equals_fail() { let res = App::new("prog") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .setting(ArgSettings::RequireEquals) .setting(ArgSettings::TakesValue) .long("config"), @@ -33,12 +33,12 @@ fn require_equals_fail() { fn require_equals_min_values_zero() { let res = App::new("prog") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .setting(ArgSettings::RequireEquals) .min_values(0) .long("config"), ) - .arg(Arg::with_name("cmd")) + .arg(Arg::new("cmd")) .try_get_matches_from(vec!["prog", "--config", "cmd"]); assert!(res.is_ok()); let m = res.unwrap(); @@ -50,7 +50,7 @@ fn require_equals_min_values_zero() { fn double_hyphen_as_value() { let res = App::new("prog") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .setting(ArgSettings::AllowHyphenValues) .long("config"), ) @@ -63,11 +63,11 @@ fn double_hyphen_as_value() { fn require_equals_no_empty_values_fail() { let res = App::new("prog") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .setting(ArgSettings::RequireEquals) .long("config"), ) - .arg(Arg::with_name("some")) + .arg(Arg::new("some")) .try_get_matches_from(vec!["prog", "--config=", "file.conf"]); assert!(res.is_err()); assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue); @@ -77,7 +77,7 @@ fn require_equals_no_empty_values_fail() { fn require_equals_empty_vals_pass() { let res = App::new("prog") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .setting(ArgSettings::RequireEquals) .setting(ArgSettings::AllowEmptyValues) .long("config"), @@ -90,7 +90,7 @@ fn require_equals_empty_vals_pass() { fn require_equals_pass() { let res = App::new("prog") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .setting(ArgSettings::RequireEquals) .long("config"), ) @@ -384,7 +384,7 @@ fn issue_665() { fn issue_1047_min_zero_vals_default_val() { let m = App::new("foo") .arg( - Arg::with_name("del") + Arg::new("del") .short('d') .long("del") .setting(ArgSettings::RequireEquals) diff --git a/tests/positionals.rs b/tests/positionals.rs index d3b0f2a8..9249849d 100644 --- a/tests/positionals.rs +++ b/tests/positionals.rs @@ -23,7 +23,7 @@ fn issue_946() { .setting(clap::AppSettings::AllowLeadingHyphen) .arg("--exact 'filters match exactly'") .arg( - clap::Arg::with_name("filter") + clap::Arg::new("filter") .index(1) .takes_value(true) .help("filters to apply to output"), @@ -41,7 +41,7 @@ fn positional() { let r = App::new("positional") .args(&[ Arg::from("-f, --flag 'some flag'"), - Arg::with_name("positional").index(1), + Arg::new("positional").index(1), ]) .try_get_matches_from(vec!["", "-f", "test"]); assert!(r.is_ok(), "{:#?}", r); @@ -53,7 +53,7 @@ fn positional() { let m = App::new("positional") .args(&[ Arg::from("-f, --flag 'some flag'"), - Arg::with_name("positional").index(1), + Arg::new("positional").index(1), ]) .get_matches_from(vec!["", "test", "--flag"]); assert!(m.is_present("positional")); @@ -106,7 +106,7 @@ fn positional_multiple() { let r = App::new("positional_multiple") .args(&[ Arg::from("-f, --flag 'some flag'"), - Arg::with_name("positional").index(1).multiple(true), + Arg::new("positional").index(1).multiple(true), ]) .try_get_matches_from(vec!["", "-f", "test1", "test2", "test3"]); assert!(r.is_ok(), "{:#?}", r); @@ -124,7 +124,7 @@ fn positional_multiple_3() { let r = App::new("positional_multiple") .args(&[ Arg::from("-f, --flag 'some flag'"), - Arg::with_name("positional").index(1).multiple(true), + Arg::new("positional").index(1).multiple(true), ]) .try_get_matches_from(vec!["", "test1", "test2", "test3", "--flag"]); assert!(r.is_ok(), "{:#?}", r); @@ -142,7 +142,7 @@ fn positional_multiple_2() { let result = App::new("positional_multiple") .args(&[ Arg::from("-f, --flag 'some flag'"), - Arg::with_name("positional").index(1), + Arg::new("positional").index(1), ]) .try_get_matches_from(vec!["", "-f", "test1", "test2", "test3"]); assert!(result.is_err()); @@ -155,7 +155,7 @@ fn positional_possible_values() { let r = App::new("positional_possible_values") .args(&[ Arg::from("-f, --flag 'some flag'"), - Arg::with_name("positional") + Arg::new("positional") .index(1) .possible_value("test123"), ]) @@ -173,14 +173,14 @@ fn positional_possible_values() { #[test] fn create_positional() { let _ = App::new("test") - .arg(Arg::with_name("test").index(1).help("testing testing")) + .arg(Arg::new("test").index(1).help("testing testing")) .get_matches_from(vec![""]); } #[test] fn positional_hyphen_does_not_panic() { let _ = App::new("test") - .arg(Arg::with_name("dummy")) + .arg(Arg::new("dummy")) .get_matches_from(vec!["test", "-"]); } diff --git a/tests/posix_compatible.rs b/tests/posix_compatible.rs index ab5cc217..9dc13b99 100644 --- a/tests/posix_compatible.rs +++ b/tests/posix_compatible.rs @@ -259,7 +259,7 @@ fn conflict_overriden_4() { #[test] fn pos_required_overridden_by_flag() { let result = App::new("require_overriden") - .arg(Arg::with_name("pos").index(1).required(true)) + .arg(Arg::new("pos").index(1).required(true)) .arg(Arg::from("-c, --color 'some flag'").overrides_with("pos")) .try_get_matches_from(vec!["", "test", "-c"]); assert!(result.is_ok(), "{:?}", result.unwrap_err()); @@ -268,7 +268,7 @@ fn pos_required_overridden_by_flag() { #[test] fn require_overriden_2() { let m = App::new("require_overriden") - .arg(Arg::with_name("req_pos").required(true)) + .arg(Arg::new("req_pos").required(true)) .arg(Arg::from("-c, --color 'other flag'").overrides_with("req_pos")) .get_matches_from(vec!["", "-c", "req_pos"]); assert!(!m.is_present("color")); diff --git a/tests/possible_values.rs b/tests/possible_values.rs index 9248e573..773973c5 100644 --- a/tests/possible_values.rs +++ b/tests/possible_values.rs @@ -33,7 +33,7 @@ For more information try --help"; fn possible_values_of_positional() { let m = App::new("possible_values") .arg( - Arg::with_name("positional") + Arg::new("positional") .index(1) .possible_value("test123"), ) @@ -50,7 +50,7 @@ fn possible_values_of_positional() { fn possible_values_of_positional_fail() { let m = App::new("possible_values") .arg( - Arg::with_name("positional") + Arg::new("positional") .index(1) .possible_value("test123"), ) @@ -64,7 +64,7 @@ fn possible_values_of_positional_fail() { fn possible_values_of_positional_multiple() { let m = App::new("possible_values") .arg( - Arg::with_name("positional") + Arg::new("positional") .index(1) .possible_value("test123") .possible_value("test321") @@ -86,7 +86,7 @@ fn possible_values_of_positional_multiple() { fn possible_values_of_positional_multiple_fail() { let m = App::new("possible_values") .arg( - Arg::with_name("positional") + Arg::new("positional") .index(1) .possible_value("test123") .possible_value("test321") @@ -102,7 +102,7 @@ fn possible_values_of_positional_multiple_fail() { fn possible_values_of_option() { let m = App::new("possible_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -121,7 +121,7 @@ fn possible_values_of_option() { fn possible_values_of_option_fail() { let m = App::new("possible_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -137,7 +137,7 @@ fn possible_values_of_option_fail() { fn possible_values_of_option_multiple() { let m = App::new("possible_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -161,7 +161,7 @@ fn possible_values_of_option_multiple() { fn possible_values_of_option_multiple_fail() { let m = App::new("possible_values") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -189,7 +189,7 @@ fn possible_values_output() { fn case_insensitive() { let m = App::new("pv") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -211,7 +211,7 @@ fn case_insensitive() { fn case_insensitive_faili() { let m = App::new("pv") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -228,7 +228,7 @@ fn case_insensitive_faili() { fn case_insensitive_multiple() { let m = App::new("pv") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) @@ -250,7 +250,7 @@ fn case_insensitive_multiple() { fn case_insensitive_multiple_fail() { let m = App::new("pv") .arg( - Arg::with_name("option") + Arg::new("option") .short('o') .long("--option") .takes_value(true) diff --git a/tests/propagate_globals.rs b/tests/propagate_globals.rs index 4e76239f..a9d1ac82 100644 --- a/tests/propagate_globals.rs +++ b/tests/propagate_globals.rs @@ -9,7 +9,7 @@ mod tests { fn get_app() -> App<'static, 'static> { App::new("myprog") .arg( - Arg::with_name("GLOBAL_ARG") + Arg::new("GLOBAL_ARG") .long("global-arg") .help("Specifies something needed by the subcommands") .setting(ArgSettings::Global) @@ -17,7 +17,7 @@ mod tests { .default_value("default_value"), ) .arg( - Arg::with_name("GLOBAL_FLAG") + Arg::new("GLOBAL_FLAG") .long("global-flag") .help("Specifies something needed by the subcommands") .setting(ArgSettings::MultipleOccurrences) diff --git a/tests/require.rs b/tests/require.rs index 61a6c4d2..4069bf75 100644 --- a/tests/require.rs +++ b/tests/require.rs @@ -78,7 +78,7 @@ fn option_required_2() { #[test] fn positional_required() { let result = App::new("positional_required") - .arg(Arg::with_name("flag").index(1).required(true)) + .arg(Arg::new("flag").index(1).required(true)) .try_get_matches_from(vec![""]); assert!(result.is_err()); let err = result.err().unwrap(); @@ -88,7 +88,7 @@ fn positional_required() { #[test] fn positional_required_2() { let m = App::new("positional_required") - .arg(Arg::with_name("flag").index(1).required(true)) + .arg(Arg::new("flag").index(1).required(true)) .get_matches_from(vec!["", "someval"]); assert!(m.is_present("flag")); assert_eq!(m.value_of("flag").unwrap(), "someval"); @@ -218,12 +218,12 @@ fn issue_753() { fn required_unless() { let res = App::new("unlesstest") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless("dbg") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) + .arg(Arg::new("dbg").long("debug")) .try_get_matches_from(vec!["unlesstest", "--debug"]); assert!(res.is_ok()); @@ -236,12 +236,12 @@ fn required_unless() { fn required_unless_err() { let res = App::new("unlesstest") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless("dbg") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) + .arg(Arg::new("dbg").long("debug")) .try_get_matches_from(vec!["unlesstest"]); assert!(res.is_err()); @@ -254,13 +254,13 @@ fn required_unless_err() { fn required_unless_all() { let res = App::new("unlessall") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless_all(&["dbg", "infile"]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) - .arg(Arg::with_name("infile").short('i').takes_value(true)) + .arg(Arg::new("dbg").long("debug")) + .arg(Arg::new("infile").short('i').takes_value(true)) .try_get_matches_from(vec!["unlessall", "--debug", "-i", "file"]); assert!(res.is_ok()); @@ -274,13 +274,13 @@ fn required_unless_all() { fn required_unless_all_err() { let res = App::new("unlessall") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless_all(&["dbg", "infile"]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) - .arg(Arg::with_name("infile").short('i').takes_value(true)) + .arg(Arg::new("dbg").long("debug")) + .arg(Arg::new("infile").short('i').takes_value(true)) .try_get_matches_from(vec!["unlessall", "--debug"]); assert!(res.is_err()); @@ -293,13 +293,13 @@ fn required_unless_all_err() { fn required_unless_one() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless_one(&["dbg", "infile"]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) - .arg(Arg::with_name("infile").short('i').takes_value(true)) + .arg(Arg::new("dbg").long("debug")) + .arg(Arg::new("infile").short('i').takes_value(true)) .try_get_matches_from(vec!["unlessone", "--debug"]); assert!(res.is_ok()); @@ -314,13 +314,13 @@ fn required_unless_one_2() { // instead of the first. let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless_one(&["dbg", "infile"]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) - .arg(Arg::with_name("infile").short('i').takes_value(true)) + .arg(Arg::new("dbg").long("debug")) + .arg(Arg::new("infile").short('i').takes_value(true)) .try_get_matches_from(vec!["unlessone", "-i", "file"]); assert!(res.is_ok()); @@ -333,10 +333,10 @@ fn required_unless_one_2() { fn required_unless_one_works_with_short() { // GitHub issue: https://github.com/kbknapp/clap-rs/issues/1135 let res = App::new("unlessone") - .arg(Arg::with_name("a").conflicts_with("b").short('a')) - .arg(Arg::with_name("b").short('b')) + .arg(Arg::new("a").conflicts_with("b").short('a')) + .arg(Arg::new("b").short('b')) .arg( - Arg::with_name("x") + Arg::new("x") .short('x') .required_unless_one(&["a", "b"]), ) @@ -348,10 +348,10 @@ fn required_unless_one_works_with_short() { #[test] fn required_unless_one_works_with_short_err() { let res = App::new("unlessone") - .arg(Arg::with_name("a").conflicts_with("b").short('a')) - .arg(Arg::with_name("b").short('b')) + .arg(Arg::new("a").conflicts_with("b").short('a')) + .arg(Arg::new("b").short('b')) .arg( - Arg::with_name("x") + Arg::new("x") .short('x') .required_unless_one(&["a", "b"]), ) @@ -363,9 +363,9 @@ fn required_unless_one_works_with_short_err() { #[test] fn required_unless_one_works_without() { let res = App::new("unlessone") - .arg(Arg::with_name("a").conflicts_with("b").short('a')) - .arg(Arg::with_name("b").short('b')) - .arg(Arg::with_name("x").required_unless_one(&["a", "b"])) + .arg(Arg::new("a").conflicts_with("b").short('a')) + .arg(Arg::new("b").short('b')) + .arg(Arg::new("x").required_unless_one(&["a", "b"])) .try_get_matches_from(vec!["unlessone", "-a"]); assert!(res.is_ok()); @@ -374,10 +374,10 @@ fn required_unless_one_works_without() { #[test] fn required_unless_one_works_with_long() { let res = App::new("unlessone") - .arg(Arg::with_name("a").conflicts_with("b").short('a')) - .arg(Arg::with_name("b").short('b')) + .arg(Arg::new("a").conflicts_with("b").short('a')) + .arg(Arg::new("b").short('b')) .arg( - Arg::with_name("x") + Arg::new("x") .long("x_is_the_option") .required_unless_one(&["a", "b"]), ) @@ -390,13 +390,13 @@ fn required_unless_one_works_with_long() { fn required_unless_one_1() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless_one(&["dbg", "infile"]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) - .arg(Arg::with_name("infile").short('i').takes_value(true)) + .arg(Arg::new("dbg").long("debug")) + .arg(Arg::new("infile").short('i').takes_value(true)) .try_get_matches_from(vec!["unlessone", "--debug"]); assert!(res.is_ok()); @@ -410,13 +410,13 @@ fn required_unless_one_1() { fn required_unless_one_err() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_unless_one(&["dbg", "infile"]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("dbg").long("debug")) - .arg(Arg::with_name("infile").short('i').takes_value(true)) + .arg(Arg::new("dbg").long("debug")) + .arg(Arg::new("infile").short('i').takes_value(true)) .try_get_matches_from(vec!["unlessone"]); assert!(res.is_err()); @@ -439,12 +439,12 @@ fn missing_required_output() { fn requires_if_present_val() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .requires_if("my.cfg", "extra") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").long("extra")) + .arg(Arg::new("extra").long("extra")) .try_get_matches_from(vec!["unlessone", "--config=my.cfg"]); assert!(res.is_err()); @@ -455,13 +455,13 @@ fn requires_if_present_val() { fn requires_if_present_mult() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .requires_ifs(&[("my.cfg", "extra"), ("other.cfg", "other")]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").long("extra")) - .arg(Arg::with_name("other").long("other")) + .arg(Arg::new("extra").long("extra")) + .arg(Arg::new("other").long("other")) .try_get_matches_from(vec!["unlessone", "--config=other.cfg"]); assert!(res.is_err()); @@ -472,13 +472,13 @@ fn requires_if_present_mult() { fn requires_if_present_mult_pass() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .requires_ifs(&[("my.cfg", "extra"), ("other.cfg", "other")]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").long("extra")) - .arg(Arg::with_name("other").long("other")) + .arg(Arg::new("extra").long("extra")) + .arg(Arg::new("other").long("other")) .try_get_matches_from(vec!["unlessone", "--config=some.cfg"]); assert!(res.is_ok()); @@ -488,12 +488,12 @@ fn requires_if_present_mult_pass() { fn requires_if_present_val_no_present_pass() { let res = App::new("unlessone") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .requires_if("my.cfg", "extra") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").long("extra")) + .arg(Arg::new("extra").long("extra")) .try_get_matches_from(vec!["unlessone"]); assert!(res.is_ok()); @@ -505,12 +505,12 @@ fn requires_if_present_val_no_present_pass() { fn required_if_val_present_pass() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_if("extra", "val") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) + .arg(Arg::new("extra").takes_value(true).long("extra")) .try_get_matches_from(vec!["ri", "--extra", "val", "--config", "my.cfg"]); assert!(res.is_ok()); @@ -520,12 +520,12 @@ fn required_if_val_present_pass() { fn required_if_val_present_fail() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_if("extra", "val") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) + .arg(Arg::new("extra").takes_value(true).long("extra")) .try_get_matches_from(vec!["ri", "--extra", "val"]); assert!(res.is_err()); @@ -539,20 +539,20 @@ fn required_if_val_present_fail_error_output() { .author("F0x06") .about("Arg test") .arg( - Arg::with_name("target") + Arg::new("target") .takes_value(true) .required(true) .possible_values(&["file", "stdout"]) .long("target"), ) .arg( - Arg::with_name("input") + Arg::new("input") .takes_value(true) .required(true) .long("input"), ) .arg( - Arg::with_name("output") + Arg::new("output") .takes_value(true) .required_if("target", "file") .long("output"), @@ -570,12 +570,12 @@ fn required_if_val_present_fail_error_output() { fn required_if_wrong_val() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_if("extra", "val") .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) + .arg(Arg::new("extra").takes_value(true).long("extra")) .try_get_matches_from(vec!["ri", "--extra", "other"]); assert!(res.is_ok()); @@ -585,13 +585,13 @@ fn required_if_wrong_val() { fn required_ifs_val_present_pass() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_ifs(&[("extra", "val"), ("option", "spec")]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("option").takes_value(true).long("option")) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) + .arg(Arg::new("option").takes_value(true).long("option")) + .arg(Arg::new("extra").takes_value(true).long("extra")) .try_get_matches_from(vec!["ri", "--option", "spec", "--config", "my.cfg"]); assert!(res.is_ok()); @@ -601,13 +601,13 @@ fn required_ifs_val_present_pass() { fn required_ifs_val_present_fail() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_ifs(&[("extra", "val"), ("option", "spec")]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) - .arg(Arg::with_name("option").takes_value(true).long("option")) + .arg(Arg::new("extra").takes_value(true).long("extra")) + .arg(Arg::new("option").takes_value(true).long("option")) .try_get_matches_from(vec!["ri", "--option", "spec"]); assert!(res.is_err()); @@ -618,13 +618,13 @@ fn required_ifs_val_present_fail() { fn required_ifs_wrong_val() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_ifs(&[("extra", "val"), ("option", "spec")]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) - .arg(Arg::with_name("option").takes_value(true).long("option")) + .arg(Arg::new("extra").takes_value(true).long("extra")) + .arg(Arg::new("option").takes_value(true).long("option")) .try_get_matches_from(vec!["ri", "--option", "other"]); assert!(res.is_ok()); @@ -634,13 +634,13 @@ fn required_ifs_wrong_val() { fn required_ifs_wrong_val_mult_fail() { let res = App::new("ri") .arg( - Arg::with_name("cfg") + Arg::new("cfg") .required_ifs(&[("extra", "val"), ("option", "spec")]) .takes_value(true) .long("config"), ) - .arg(Arg::with_name("extra").takes_value(true).long("extra")) - .arg(Arg::with_name("option").takes_value(true).long("option")) + .arg(Arg::new("extra").takes_value(true).long("extra")) + .arg(Arg::new("option").takes_value(true).long("option")) .try_get_matches_from(vec!["ri", "--extra", "other", "--option", "spec"]); assert!(res.is_err()); @@ -650,7 +650,7 @@ fn required_ifs_wrong_val_mult_fail() { #[test] fn require_eq() { let app = App::new("clap-test").version("v1.4.8").arg( - Arg::with_name("opt") + Arg::new("opt") .long("opt") .short('o') .required(true) diff --git a/tests/subcommands.rs b/tests/subcommands.rs index c2036a01..9852c62d 100644 --- a/tests/subcommands.rs +++ b/tests/subcommands.rs @@ -57,14 +57,14 @@ fn subcommand() { let m = App::new("test") .subcommand( App::new("some").arg( - Arg::with_name("test") + Arg::new("test") .short('t') .long("test") .takes_value(true) .help("testing testing"), ), ) - .arg(Arg::with_name("other").long("other")) + .arg(Arg::new("other").long("other")) .get_matches_from(vec!["myprog", "some", "--test", "testing"]); assert_eq!(m.subcommand_name().unwrap(), "some"); @@ -78,14 +78,14 @@ fn subcommand_none_given() { let m = App::new("test") .subcommand( App::new("some").arg( - Arg::with_name("test") + Arg::new("test") .short('t') .long("test") .takes_value(true) .help("testing testing"), ), ) - .arg(Arg::with_name("other").long("other")) + .arg(Arg::new("other").long("other")) .get_matches_from(vec![""]); assert!(m.subcommand_name().is_none()); @@ -96,15 +96,15 @@ fn subcommand_multiple() { let m = App::new("test") .subcommands(vec![ App::new("some").arg( - Arg::with_name("test") + Arg::new("test") .short('t') .long("test") .takes_value(true) .help("testing testing"), ), - App::new("add").arg(Arg::with_name("roster").short('r')), + App::new("add").arg(Arg::new("roster").short('r')), ]) - .arg(Arg::with_name("other").long("other")) + .arg(Arg::new("other").long("other")) .get_matches_from(vec!["myprog", "some", "--test", "testing"]); assert!(m.subcommand_matches("some").is_some()); @@ -214,9 +214,9 @@ fn issue_1031_args_with_same_name_no_more_vals() { fn issue_1161_multiple_hyphen_hyphen() { // from example 22 let res = App::new("myprog") - .arg(Arg::with_name("eff").short('f')) - .arg(Arg::with_name("pea").short('p').takes_value(true)) - .arg(Arg::with_name("slop").multiple(true).last(true)) + .arg(Arg::new("eff").short('f')) + .arg(Arg::new("pea").short('p').takes_value(true)) + .arg(Arg::new("slop").multiple(true).last(true)) .try_get_matches_from(vec![ "-f", "-p=bob", diff --git a/tests/tests.rs b/tests/tests.rs index 68d7cc21..3bec865d 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -311,8 +311,8 @@ fn create_app() { fn add_multiple_arg() { let _ = App::new("test") .args(&[ - Arg::with_name("test").short('s'), - Arg::with_name("test2").short('l'), + Arg::new("test").short('s'), + Arg::new("test2").short('l'), ]) .get_matches_from(vec![""]); } diff --git a/tests/unique_args.rs b/tests/unique_args.rs index b24f85fd..39de71ef 100644 --- a/tests/unique_args.rs +++ b/tests/unique_args.rs @@ -7,8 +7,8 @@ use clap::{App, Arg}; fn unique_arg_names() { let _ = App::new("some") .args(&[ - Arg::with_name("arg").short('a'), - Arg::with_name("arg").short('b'), + Arg::new("arg").short('a'), + Arg::new("arg").short('b'), ]) .try_get_matches(); } @@ -18,8 +18,8 @@ fn unique_arg_names() { fn unique_arg_shorts() { let _ = App::new("some") .args(&[ - Arg::with_name("arg1").short('a'), - Arg::with_name("arg2").short('a'), + Arg::new("arg1").short('a'), + Arg::new("arg2").short('a'), ]) .try_get_matches(); } @@ -29,8 +29,8 @@ fn unique_arg_shorts() { fn unique_arg_longs() { let _ = App::new("some") .args(&[ - Arg::with_name("arg1").long("long"), - Arg::with_name("arg2").long("long"), + Arg::new("arg1").long("long"), + Arg::new("arg2").long("long"), ]) .try_get_matches(); }