mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 15:27:16 +00:00
fix(error): Include failed arg in usage in --flag=bad-value error
This commit is contained in:
parent
12d76d649a
commit
cb1cd67009
2 changed files with 3 additions and 2 deletions
|
@ -778,7 +778,7 @@ impl<'cmd> Parser<'cmd> {
|
|||
"Parser::parse_long_arg({:?}): Got invalid literal `{:?}`",
|
||||
long_arg, rest
|
||||
);
|
||||
let used: Vec<Id> = matcher
|
||||
let mut used: Vec<Id> = matcher
|
||||
.arg_ids()
|
||||
.filter(|arg_id| {
|
||||
matcher.check_explicit(arg_id, &crate::builder::ArgPredicate::IsPresent)
|
||||
|
@ -790,6 +790,7 @@ impl<'cmd> Parser<'cmd> {
|
|||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
used.push(arg.get_id().clone());
|
||||
|
||||
Ok(ParseResult::UnneededAttachedValue {
|
||||
rest: rest.to_str_lossy().into_owned(),
|
||||
|
|
|
@ -142,7 +142,7 @@ fn unexpected_value_error() {
|
|||
const USE_FLAG_AS_ARGUMENT: &str = "\
|
||||
error: The value 'foo' was provided to '--a-flag' but it wasn't expecting any more values
|
||||
|
||||
Usage: mycat [OPTIONS] [filename]
|
||||
Usage: mycat --a-flag [filename]
|
||||
|
||||
For more information try '--help'
|
||||
";
|
||||
|
|
Loading…
Add table
Reference in a new issue