-
-
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
Help text for -h
is too long for two-column short help
#4409
Comments
Framing this in a different way, what do you see is the appropriate reserved size for the flag column and the help column? Without having a guiding number, it is hard to make decisions on what are appropriate trade offs. |
I think it makes sense to leave those tradeoffs to the application as much as possible. In my application we have one subcommand with really tight spacing constraints, where we've sometimes had to choose between shortening a value name or rewording a help text to keep to 80 columns while retaining as much clarity as possible. (And we've had to carefully choose long option names as well.) Having the flexibility to trade one column against the other is helpful here, and the shorter the |
Anything I can do to help unblock this? The fix for this regression is just a string change, which should be ready to go in #4408. |
imo "as short as possible" and contorting the text to do so, is not acceptable. We should have a suggested length so we can better discuss acceptable trade offs in what we do with the clarity of the text. |
In my experience, short help text always has to be contorted for compactness, similar to fitting a meaningful Git commit summary into 50 characters. In the application I mentioned, using clap 4, the tightest constraint is a subcommand that needs 27 characters for long options and (abbreviated) value names. Subtracting 8 characters for short options and padding, that leaves 45 characters for short help. It's maybe worth noting that the reason we're so aggressive about optimizing short help is that if any one option exceeds the character limit, clap sparsifies the entire help section, rather than merely wrapping that message onto a second line within its column. We even ended up adding a CI check for it. That's out of scope for this issue, of course. #4405 currently uses 30 characters for |
I suspect some additional constraints are at play as I see ripgrep and cargo seem to be fairly generous with their short helps. Some additional context would help.
That might be the more important conversation to have though (over in #3300 most likely) |
cargo and ripgrep both allow their help lines to overflow the terminal onto a second line, sometimes breaking in the middle of a word. That's functional but doesn't seem especially readable. Re context, this is a low-level tool (an OS installer) which is often run from a Linux virtual console (not a graphical session). It has many options, and most users probably don't run it often enough to memorize its CLI. So I'd expect the short help to be consulted fairly often, and would like it to be nicely formatted and not to produce many screenfuls of text. These seem like reasonable goals for many programs though. Re line wrapping, I'll comment over in #3300. |
This is an intermediate solution for clap-rs#4408. As there were no agreeed upon goals, I went with what I felt read well and that I saw commonly used on non-clap commands. I originally favored `Print this help` but realied that doesn't read correctly in completions. Fixes clap-rs#4409
This is an intermediate solution for clap-rs#4408. As there were no agreeed upon goals, I went with what I felt read well and that I saw commonly used on non-clap commands. - "information" isn't really a necessary word. - I originally favored `Print this help` but realied that doesn't read correctly in completions. - Besides being shorter, the reason for the flipped short/long hint is it gives people the context they need for scanning, emphasizing "summary" and "more". Fixes clap-rs#4409
Please complete the following tasks
Rust Version
rustc 1.64.0 (Fedora 1.64.0-1.fc36)
Clap Version
4.0.17
Minimal reproducible code
Cargo.toml:
Steps to reproduce the bug with the above code
Actual Behaviour
On an 80-column terminal, short help uses multiple lines per option:
Expected Behaviour
Short help uses two-column format:
Additional Context
Applications may want to constrain their short help to use the two-column format so the
-h
output is as compact as possible. They might do this by optimizing short help texts to fit within the right-hand column on 80-character terminals, and then providing long help texts with more info. However, #4159 made the short help text for-h
/--help
much longer when the short and long help are different, forcing short help to wrap to the multiple-line format if medium-sized option/value names are used.Proposed fix in #4408.
Debug Output
No response
The text was updated successfully, but these errors were encountered: