mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
Fix usage of positional grouped arguments uses arg name rather than val_name
This commit is contained in:
parent
d7f6748887
commit
5ee6e07858
2 changed files with 27 additions and 1 deletions
|
@ -2575,8 +2575,10 @@ impl<'help> App<'help> {
|
|||
.filter_map(|x| self.find(x))
|
||||
.map(|x| {
|
||||
if x.index.is_some() {
|
||||
x.name.to_owned()
|
||||
// Print val_name for positional arguments. e.g. <file_name>
|
||||
x.name_no_brackets().to_string()
|
||||
} else {
|
||||
// Print useage string for flags arguments, e.g. <--help>
|
||||
x.to_string()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -274,6 +274,30 @@ fn group_multiple_args_error() {
|
|||
assert_eq!(err.kind, ErrorKind::ArgumentConflict);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_usage_use_val_name() {
|
||||
static GROUP_USAGE_USE_VAL_NAME: &str = "prog
|
||||
|
||||
USAGE:
|
||||
prog <A>
|
||||
|
||||
ARGS:
|
||||
<A>
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
-V, --version Prints version information";
|
||||
let app = App::new("prog")
|
||||
.arg(Arg::new("a").value_name("A"))
|
||||
.group(ArgGroup::new("group").arg("a").required(true));
|
||||
assert!(utils::compare_output(
|
||||
app,
|
||||
"prog --help",
|
||||
GROUP_USAGE_USE_VAL_NAME,
|
||||
false,
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_acts_like_arg() {
|
||||
let m = App::new("prog")
|
||||
|
|
Loading…
Add table
Reference in a new issue