-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementingStatus: Waiting on user-facing design to be resolved before implementing
Milestone
Description
We are looking to polish the help as part of the v4 release since some parts of an applications help might be dependent on how clap renders things (e.g. to match clap's ALL CAPS help headings, a user might put theirs in ALL CAPS).
So far we have made the following changes:
- The greens and yellows are gone, instead using bold, underline, and
dimmed: PR 4117 though some more work might be needed to enable colored help, depending on the needs- See PR for screenshot
- Dimmed was removed from placeholders in fix(help): Don't dim placeholders #4126
- Some liked the colors (example), some hated them (example)
- Color makes it easier to scan
- Some applications have specific branding that it clashed with (Make colored help output more compatible with an applications overall theme #2963)
- True colors would be prettier but requires getting into terminal theme detection to make sure it plays nice and hesistant to do that at the moment
- Users can't rollback until theming support is in (Allow good/warning/error/hint color to be customized #3234) though they can just disable the coloring with
Command::disable_colored_help(true)
- Reduce the ALL CAPS: PR 4123
- See PR for screenshot
- ARGS and OPTIONS matched the usage and worked as non-colored headings but it feels a bit unpolished
- I was hard pressed to find other CLIs that do this
- All caps mirrors man pages
- Mixed with underlining, it can be hard to see the bottom of "y", "g", etc.
- Users can rollback to the old behavior with
Command::help_template
,Command:subcommand_help_heading
, andArg::help_heading
- List subcommands before args/options: PR 4125
- See PR for screenshot
- At the end represents where someone might put it in the usage compared to everything else but generally a user's primary focus is on the subcommand they are going to call so that is where the help's focus should be
- Users can rollback to the old behavior with
Command::help_template
- List of positional Arguments use
[]
for optional PR 4144 - Always show optional positional arguments in usage, rather than collapsing them PR 4151
- Generally there will be few enough positional arguments that this shouldn't be a big deal
- Optional flags/options can be more numerous and clog up the usage, making it impossible to deal with (e.g.
git
)
- Renaming SUBCOMMAND value name and Subcommand section headers to COMMAND and Command: PR 4155
- "Subcommand" looks weird to me
- Hard pressed to find other CLIs that do this
- Users can rollback to the old behavior with
Command::subcommand_help_heading
andCommand::subcommand_value_name
- Hint to the user the difference between
-h
and--help
: PR 4159 - Remove
<name> <verson>
from the start of--help
: PR 4160- It takes up precious vertical space but doesn't seem justified, especially when
--version
exists and when a subcommand doesn't have a version, it feels out of place (seecargo check -h
) - Again, hard pressed to find other CLIs that do this
- This does leave where to put authors if people specify them
- Since all help is rendered from a template, this runs into problems when
Command::about
is unspecified as it leaves a blank line at the top of the help. fix(help): Always trim output #4156 resolves that - Users can rollback to the old behavior with
Command::help_template
- It takes up precious vertical space but doesn't seem justified, especially when
- Collapse usage to one line PR 4188
- After looking at several CLIs, it seemed to fit and helps reduce length of output
- See Polishing
--help
output #4132 (comment) for alternatives considered
- Reduce blank lines when overflowing short help onto next line PR 4190
- Reduce indentation from 4 to 2 to reduce the chance of wrapping PR 4192
- flags/options already have a lot of whitespace, we probably don't need as much everywhere
- Inspired by
podman -h
- While refactor(help): Reduce magic numbers for indentation #4161 will make it easier to do on the implementation side, I'm losing steam and don't want to go update all of those tests
Rejected
- Some CLIs put Usage before the
<about>
and collapse it toUsage: <usage>
if its a single line (e.g.find --help
)- Putting usage closer to the arguments seems better
- Otherwise, the difference seems trivial without a reason to go one way or the other
- Should Arguments and Options be under a single heading by default?
- I feel like there is a distinct enough difference in how they are used to call them out separately
- A user can force them to be merged via
Arg::help_heading
Future improvements
- Clap derive should parse markdown doc comment into normal text #2389
- Allow good/warning/error/hint color to be customized #3234
- The header for my examples are not colored like the others #3108
- Allow styled text in
template
#1433 - Multiple subcommand categories /
help_heading
s #1553
Note: While I mentioning non-clap CLIs, I want to be clear that we don't just want to conform to what is out there. We should be aiming to make the defaults as polished as possible which can include taking inspiration from others.
weihanglo, mrvollger, gnprice, schneiderfelipe and WilfredPatchMixolydic, melMass, IndigoLily, StuSerious, Jascha-N and 5 moregnprice and schneiderfelipe
Metadata
Metadata
Assignees
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementingStatus: Waiting on user-facing design to be resolved before implementing