diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs index 25303145e11..ade62d78ce2 100644 --- a/src/build/arg/mod.rs +++ b/src/build/arg/mod.rs @@ -1701,6 +1701,7 @@ impl<'help> Arg<'help> { } /// Specifies the name of the [`ArgGroup`] the argument belongs to. + /// **The group must be defined separately via `App::group`.** /// /// # Examples /// @@ -1716,7 +1717,7 @@ impl<'help> Arg<'help> { /// was one of said arguments. /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{App, Arg, ArgGroup}; /// let m = App::new("prog") /// .arg(Arg::new("debug") /// .long("debug") @@ -1724,6 +1725,7 @@ impl<'help> Arg<'help> { /// .arg(Arg::new("verbose") /// .long("verbose") /// .group("mode")) + /// .group(ArgGroup::new("mode")) /// .get_matches_from(vec![ /// "prog", "--debug" /// ]); @@ -1736,6 +1738,7 @@ impl<'help> Arg<'help> { } /// Specifies the names of multiple [`ArgGroup`]'s the argument belongs to. + /// **The groups must be defined separately via `App::group`.** /// /// # Examples /// @@ -1751,7 +1754,7 @@ impl<'help> Arg<'help> { /// was one of said arguments. /// /// ```rust - /// # use clap::{App, Arg}; + /// # use clap::{App, Arg, ArgGroup}; /// let m = App::new("prog") /// .arg(Arg::new("debug") /// .long("debug") @@ -1759,6 +1762,8 @@ impl<'help> Arg<'help> { /// .arg(Arg::new("verbose") /// .long("verbose") /// .groups(&["mode", "verbosity"])) + /// .group(ArgGroup::new("mode")) + /// .group(ArgGroup::new("verbosity")) /// .get_matches_from(vec![ /// "prog", "--debug" /// ]); @@ -3810,7 +3815,7 @@ impl<'help> Arg<'help> { /// ]); /// /// assert!(res.is_ok()); - /// assert_eq!(res.unwrap().value_of("config"), None); + /// assert_eq!(res.unwrap().value_of("cfg"), Some("")); /// ``` /// [`ArgSettings::TakesValue`]: ./enum.ArgSettings.html#variant.TakesValue #[inline] diff --git a/tests/groups.rs b/tests/groups.rs index 40bd3b14291..e977e81f1a7 100644 --- a/tests/groups.rs +++ b/tests/groups.rs @@ -281,6 +281,7 @@ fn group_acts_like_arg() { let m = App::new("prog") .arg(Arg::new("debug").long("debug").group("mode")) .arg(Arg::new("verbose").long("verbose").group("mode")) + .group(ArgGroup::new("mode")) .get_matches_from(vec!["prog", "--debug"]); assert!(m.is_present("mode")); } diff --git a/tests/help.rs b/tests/help.rs index 1b1bc5601f7..20f340eb68b 100644 --- a/tests/help.rs +++ b/tests/help.rs @@ -35,7 +35,7 @@ FLAGS: -V, --version Prints version information OPTIONS: - -O, --Option specific vals [possible values: fast, slow] + -O, --Option3 specific vals [possible values: fast, slow] --long-option-2 tests long options with exclusions --maxvals3 ... Tests 3 max vals --minvals2 ... Tests 2 min vals diff --git a/tests/possible_values.rs b/tests/possible_values.rs index 9583b3f2276..a89f2f7f21b 100644 --- a/tests/possible_values.rs +++ b/tests/possible_values.rs @@ -3,22 +3,22 @@ mod utils; use clap::{App, Arg, ErrorKind}; #[cfg(feature = "suggestions")] -static PV_ERROR: &str = "error: 'slo' isn't a valid value for '--Option ' +static PV_ERROR: &str = "error: 'slo' isn't a valid value for '--Option3 ' \t[possible values: fast, slow] \tDid you mean 'slow'? USAGE: - clap-test --Option + clap-test --Option3 For more information try --help"; #[cfg(not(feature = "suggestions"))] -static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option ' +static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option3 ' \t[possible values: fast, slow] USAGE: - clap-test --Option + clap-test --Option3 For more information try --help"; diff --git a/tests/utils.rs b/tests/utils.rs index 5c0f96c2a5b..15d728359ad 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -85,7 +85,7 @@ pub fn complex_app() -> App<'static> { .conflicts_with("option") .requires("positional2"), Arg::from("[positional2] 'tests positionals with exclusions'"), - Arg::from("-O --Option [option3] 'specific vals'").possible_values(&opt3_vals), + Arg::from("-O --Option3 [option3] 'specific vals'").possible_values(&opt3_vals), Arg::from("[positional3]... 'tests specific values'").possible_values(&pos3_vals), Arg::from("--multvals [one] [two] 'Tests mutliple values, not mult occs'"), Arg::from("--multvalsmo... [one] [two] 'Tests mutliple values, and mult occs'"),