help: enable auto-wrapping of help output#9633
Conversation
AlexWaygood
left a comment
There was a problem hiding this comment.
You beat me by 5 minutes! My version of this PR is still compiling locally 😄
4da48d4 to
d7185f7
Compare
Previously, without the 'wrap_help' feature enabled, Clap would not do any auto-wrapping of help text. For help text with long lines, this tends to lead to non-ideal formatting. It can be especially difficult to read when the width of the terminal is smaller. This commit enables 'wrap_help', which will automatically cause Clap to query the terminal size and wrap according to that. Or, if the terminal size cannot be determined, it will default to a maximum line width of 100. Ref #9599 (comment)
d7185f7 to
92497ac
Compare
AlexWaygood
left a comment
There was a problem hiding this comment.
Nice that the --help in the docs is now neatly formatted as well :D
|
| /// Returns the output of a given subcommand (e.g., `ruff help check`). | ||
| fn subcommand_help_text(subcommand: &str) -> Result<String> { | ||
| let mut cmd = args::Args::command(); | ||
| let mut cmd = args::Args::command().term_width(79); |
There was a problem hiding this comment.
Andrew's abiding by PEP-8, clearly: https://peps.python.org/pep-0008/#maximum-line-length
There was a problem hiding this comment.
But it's not python and it's not code... I just found it funny that it's 79 and not like 80
There was a problem hiding this comment.
Anyway, I don't think it matters because markdown is not whitespace sensitive, so I don't think the rendering changes on the website
There was a problem hiding this comment.
Yeah Markdown won't care. I've been using 79 columns since forever, so I just wrote that here.
(The actual reason why I use a somewhat short line width more generally is so I can have code windows side-by-side, at a reasonable font size, without auto-line-wrapping kicking in.)


Previously, without the 'wrap_help' feature enabled, Clap would not do
any auto-wrapping of help text. For help text with long lines, this
tends to lead to non-ideal formatting. It can be especially difficult to
read when the width of the terminal is smaller.
This commit enables 'wrap_help', which will automatically cause Clap to
query the terminal size and wrap according to that. Or, if the terminal
size cannot be determined, it will default to a maximum line width of
100.
Ref #9599 (comment)