-
Notifications
You must be signed in to change notification settings - Fork 1.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: enable auto-wrapping of help output #9633
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, why 79 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Andrew's abiding by PEP-8, clearly: https://peps.python.org/pep-0008/#maximum-line-length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)