-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clap-rs 0.7.1: dynamic usage strings seem 'inverted' #96
Comments
Thanks for the detailed report! I agree, as I was thinking about this last night, it should state which arguments were missing such as your last:
This should be a decently simple change. I'll start working on this today. Also, as for why One last kind of side note, the
They may mistakenly think
I'll post back here once I've got fixes! |
I was able to reproduce the bug with this snippet, but if you have a link to your source I'd still like to see that to see how exactly your requirements are set up so I don't fix the bug in my test case, but not in your real case. let u_names = ["mode", "file"];
let matches = App::new("MyApp")
.arg(Arg::from_usage("-f [f]... 'some value'")
.value_names(&u_names)
.required(true))
.arg(Arg::from_usage("<gid> 'other value'"))
.get_matches(); Which produces grammarr: fake
USAGE:
fake <gid> [FLAGS] [ -f <mode> <file> ]
FLAGS:
-h, --help Prints help information
-v, --version Prints version information
OPTIONS:
-f <mode> <file> some value
POSITIONAL ARGUMENTS:
gid other value And when run with incomplete One or more required arguments were not supplied
USAGE:
fake
For more information try --help |
Bug fixes, performance changes, and some clean up Fixes #96
Take a look at the latest version (0.7.2 on crates.io) or master here and let me know if that works for you. It now tells you exactly which arguments you're missing (if any), along some visual clean up (spaces between arguments). I still need to fix the tab alignment in the help info, but I may wait on that as it's minor right now. Also, the requirements all should be working, i.e. you can make an argument required by default, and if it requires other arguments, those arguments will be listed in the default usage string as well...kind of "required by proxy" One other visual thing I changed was the |
I finally got around to testing the modifications (with v0.7.5 actually), and must say that the help and usage strings now seems perfect. I'd have nothing to add here, except for saying thanks ! |
With a program exhibiting the following grammar ...
... I would expect a partial invocation like
groupsmigration1 archive insert
to yield a usage more along the lines of ...... but what you get is just as follows:
Another example for missing required parameters is
groupsmigration1 archive insert -u simple README.md
where<group-id>
is missing. However, this is not actually said in the resulting usage text:What I would expect here is something like this:
In a call like
groupsmigration1 archive insert group
one will see a usage string like this:and I think think it would be much better to get something like that:
Once the usage is improved,
clap
will finally be top-of-the-line when it comes to usability I think, and I really want it to be there :).Thanks for taking care.
The text was updated successfully, but these errors were encountered: