Skip to content
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

fix(help): Shorten --help short help to shorten short help #4408

Closed
wants to merge 2 commits into from
Closed

fix(help): Shorten --help short help to shorten short help #4408

wants to merge 2 commits into from

Conversation

bgilbert
Copy link
Contributor

@bgilbert bgilbert commented Oct 20, 2022

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.

Reword the short help for this case to be as compact as possible. The net length is still a few characters longer than in clap 3, but this still substantially increases the maximum width of the left column while continuing to document the difference between -h and --help.

Also use single quotes around the strings -h and --help in help output. This is more consistent and improves readability a bit.

Fixes #4409.

@bgilbert bgilbert marked this pull request as draft October 20, 2022 15:22
@bgilbert bgilbert marked this pull request as ready for review October 20, 2022 15:29
src/builder/command.rs Outdated Show resolved Hide resolved
src/builder/command.rs Outdated Show resolved Hide resolved
src/builder/command.rs Outdated Show resolved Hide resolved
@bgilbert
Copy link
Contributor Author

Updated for comments!

Use single quotes around the strings `-h` and `--help` in help output.
This is more consistent and improves readability a bit.
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, c1c269b 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.

Reword the short help for this case to be as compact as possible.  The
net length is still a few characters longer than in clap 3, but this still
substantially increases the maximum width of the left column while
continuing to document the difference between -h and --help.

Fixes #4409
@bgilbert
Copy link
Contributor Author

And CI is now passing.

epage added a commit to epage/clap that referenced this pull request Jan 3, 2023
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.
epage added a commit to epage/clap that referenced this pull request Jan 3, 2023
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
epage added a commit to epage/clap that referenced this pull request Jan 3, 2023
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
@epage
Copy link
Member

epage commented Jan 3, 2023

#4601 superseded this,

@epage epage closed this Jan 3, 2023
@bgilbert bgilbert deleted the help branch January 3, 2023 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help text for -h is too long for two-column short help
2 participants