-
-
Notifications
You must be signed in to change notification settings - Fork 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
Context-Aware Multiple Usage from Argument Groups #4191
Comments
Rather than applying a cartesian product across every We'll also want to look at several clap users today that use groups to verify any assumptions of how well this would work and if any tweaks might be needed. A challenge for this will be balancing a usability improvement like this with our efforts to reduce compile time (#2037) and binary size (#1365) which are top complaints of clap today.
clap will automatically generate two usage statements if |
Agreed. Having per- I would say, it may be possible to be even more granular and supply a per-argument within a group usage generation option. For example, the method
I can perform a preliminary search of this and report back some results here.
Noted. Extending the interface of the |
https://github.com/clap-rs/clap/blob/master/src/output/usage.rs Tests would either go in |
Please complete the following tasks
Clap Version
3.2.20
Describe your use case
Currently, the only method, as far as I am aware, to generate a USAGE section with more than two usage statements from a set of grouped positional arguments is to explicitly pass a string to
clap::builder::Command::override_usage
.However, opting-in for this solution disables the useful context-aware capabilities that the library has to offer. For example, if a new set of positional arguments are added, the resulting USAGE section does not reflect these changes without explicitly adjusting the call to
override_usage
.To provide a small working example, a small demonstration of the
grep
tool usage without overriding the usage section would be as follows:This results in the following USAGE section:
However, the desirable output, only acquirable by overriding the usage string and losing context-aware generation is:
Describe the solution you'd like
As a result, grouped arguments (especially positional), should be given the option to generate multiple USAGE statements for every possible combination (i.e., perform the cartesian product over each
ArgGroup
).The interface for this option could look as follows:
Which, would generate the following USAGE section (assuming the same arguments as defined in the previous section):
Alternatives, if applicable
The only alternative to this is to use the
clap::build::Command::override_usage
which, as stated above, inhibits the context-aware generation of the USAGE section.Additional Context
From my own search, there are only two instances where multiple usage statements are discussed:
App::override_usage()
#3413The issue above only discusses making the USAGE string more intuitive to write and does not discuss the matter of deriving a USAGE section from the context-aware
ArgGroup
s.This discussion is over two years old. However, I would argue that the use-case and need for the feature are still relevant and possibly more feasible with the more recent versions.
The text was updated successfully, but these errors were encountered: