Add attributes to configure usage line in --help #201
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consider the cargo build as an example:
Currently with how argh generate usage line this would look like:
It's too long, barely readable, and also looks terrible when it gets split in multiple lines by the terminal. And there's no option around it.
We already provide an exhausting information in help. So I suggest adding an option to only outline the most useful parameters in usage, for example the following:
This is done by adding
usageattribute to fields we want to see in usage, other option are then hidden from the usage line by default.There is also a catch-all option to override the usage line entirely, so it's possible to reproduce what cargo build command has.
Producing:
I also rearranged components in the generated usage line and added a
[--]hint. Previously positional arguments went first before options, which is kinda misleading, since positionals may themselves start with-.So without subcommand it's now
[options...] [--] [positional...]and with it[options...] [positional...] [subcommand...].The fuchsia cli guide doesn't specify on this. And I hasn't found any reason for why it wasn't that way before.