You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hopefully the title is clear. In the example, argument foo is required, and it also requiresbar.
let matches = App::new("MyApp").arg(Arg::with_name("foo").help("FOO").short("f").required(true).takes_value(true).conflicts_with("c").requires("bar")).arg(Arg::with_name("bar").short("b").takes_value(true).help("BAR")//.required(true)).get_matches();
Calling ./prog --help returns what you'd expect (foo and bar are required, with the correct usage string), but supplying the -f flag produces the following error:
error: The following required arguments were not provided:
-b <bar>
-b <bar>
USAGE:
repeat_errors [FLAGS] [OPTIONS] -f <foo> -b <bar> -b <bar>
(Uncommenting the bar.required(true) adds another -b <bar> to the error and usage.)
It's conceivable that someone would want a required argument that requires another, so there is understandably a use case in which this error occurs. Additionally, it is certainly possible for a user to have accidentally made barrequired, and the usage mistake might easily go unnoticed.
Apologies if there's already a way to avoid these kinds of redundancies, but I didn't see any.
It seems like an interesting (albiet niche) problem, so I'll probably take a crack at solving it and make a pull request.
The text was updated successfully, but these errors were encountered:
I agree it's possible someone could end up doing this either by accident, or just not knowing there are other ways to accomplish this (i.e. if an arg is required by another required arg, it's not necessary to set).
Hopefully the title is clear. In the example, argument
foo
isrequired
, and it alsorequires
bar
.Calling
./prog --help
returns what you'd expect (foo
andbar
are required, with the correct usage string), but supplying the-f
flag produces the following error:(Uncommenting the
bar.required(true)
adds another-b <bar>
to the error and usage.)It's conceivable that someone would want a
required
argument thatrequires
another, so there is understandably a use case in which this error occurs. Additionally, it is certainly possible for a user to have accidentally madebar
required
, and the usage mistake might easily go unnoticed.Apologies if there's already a way to avoid these kinds of redundancies, but I didn't see any.
It seems like an interesting (albiet niche) problem, so I'll probably take a crack at solving it and make a pull request.
The text was updated successfully, but these errors were encountered: