Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Jul 3, 2020
1 parent 2634617 commit 67e9ba4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/build/arg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -1716,14 +1717,15 @@ 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")
/// .group("mode"))
/// .arg(Arg::new("verbose")
/// .long("verbose")
/// .group("mode"))
/// .group(ArgGroup::new("mode"))
/// .get_matches_from(vec![
/// "prog", "--debug"
/// ]);
Expand All @@ -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
///
Expand All @@ -1751,14 +1754,16 @@ 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")
/// .groups(&["mode", "verbosity"]))
/// .arg(Arg::new("verbose")
/// .long("verbose")
/// .groups(&["mode", "verbosity"]))
/// .group(ArgGroup::new("mode"))
/// .group(ArgGroup::new("verbosity"))
/// .get_matches_from(vec![
/// "prog", "--debug"
/// ]);
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions tests/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FLAGS:
-V, --version Prints version information
OPTIONS:
-O, --Option <option3> specific vals [possible values: fast, slow]
-O, --Option3 <option3> specific vals [possible values: fast, slow]
--long-option-2 <option2> tests long options with exclusions
--maxvals3 <maxvals>... Tests 3 max vals
--minvals2 <minvals>... Tests 2 min vals
Expand Down
8 changes: 4 additions & 4 deletions tests/possible_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <option3>'
static PV_ERROR: &str = "error: 'slo' isn't a valid value for '--Option3 <option3>'
\t[possible values: fast, slow]
\tDid you mean 'slow'?
USAGE:
clap-test --Option <option3>
clap-test --Option3 <option3>
For more information try --help";

#[cfg(not(feature = "suggestions"))]
static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option <option3>'
static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option3 <option3>'
\t[possible values: fast, slow]
USAGE:
clap-test --Option <option3>
clap-test --Option3 <option3>
For more information try --help";

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'"),
Expand Down

0 comments on commit 67e9ba4

Please sign in to comment.