mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-11 04:47:18 +00:00
help: enable auto-wrapping of help output (#9633)
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 https://github.com/astral-sh/ruff/pull/9599#discussion_r1464992692
This commit is contained in:
parent
b0d6fd7343
commit
fc3e2664f9
5 changed files with 102 additions and 41 deletions
|
@ -114,12 +114,15 @@ pub(super) fn main(args: &Args) -> Result<()> {
|
|||
|
||||
/// Returns the output of `ruff help`.
|
||||
fn help_text() -> String {
|
||||
args::Args::command().render_help().to_string()
|
||||
args::Args::command()
|
||||
.term_width(79)
|
||||
.render_help()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
||||
// The build call is necessary for the help output to contain `Usage: ruff
|
||||
// check` instead of `Usage: check` see https://github.com/clap-rs/clap/issues/4685
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue