-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
283d966
to
b5163b6
Compare
Last commit closes #7428 and denies multiple values from being separated by spaces any longer, as this conflicts with values being able to start with hyphens ( |
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.
If we're able to properly detect the terminal width why force 100 characters?
parity/cli/usage.rs
Outdated
help.push_str($group_name); help.push_str(":\n"); | ||
|
||
$( | ||
help.push_str(&format!("\t{}\n\t\t{}\n", $flag_usage, $flag_help)); | ||
help.push_str(&format!(" {}\n{}\n", $flag_usage, | ||
indent(fill($flag_help, term_width-8).as_ref()," ") |
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.
Could you extract this into a variable (const INDENT_PREFIX: &str = " ";). And then you can replace the 8
with INDENT_PREFIX.len()
.
@andresilva I think because it's not very readable to have such long lines on wide screens #2913 (comment) |
We can still use the terminal width, but limit it to 120 chars max. |
@axelchalon makes sense. I don't really have strong opinions on what the maximum should be (100 vs 120), maybe whatever looks better on wide screens. https://gist.github.com/axelchalon/d2aa66d26e19ea8f5484150af1a2ea62#file-gistfile1-txt-L16 Overall the code and the resulting help output LGTM. |
@5chdn currently, terminal width is used but limited to 100 characters. I don't have an opinion on 100 vs 120 characters either; whichever is preferred! @andresilva yes, you're right. last commit fixes this; I updated the gists |
Just played around with my terminal, 120 is pretty readable on a wide-screen. I would not go above that, and smaller terminals should just auto-detect the width. With high-resolution screens available I think it's fine to go for 120 over 100. 100 or even 80 (IBM punch card style) might be too narrow. |
👍 Gists are updated |
Why |
* Update Clap dependency and remove workarounds * WIP * Remove line breaks in help messages for now * Multiple values can only be separated by commas (closes #7428) * Grumbles; refactor repeating code; add constant * Use a single Wrapper rather than allocate a new one for each call * Wrap --help to 120 characters rather than 100 characters
* Update Clap dependency and remove workarounds * WIP * Remove line breaks in help messages for now * Multiple values can only be separated by commas (closes #7428) * Grumbles; refactor repeating code; add constant * Use a single Wrapper rather than allocate a new one for each call * Wrap --help to 120 characters rather than 100 characters
* Update Clap dependency and remove workarounds * WIP * Remove line breaks in help messages for now * Multiple values can only be separated by commas (closes #7428) * Grumbles; refactor repeating code; add constant * Use a single Wrapper rather than allocate a new one for each call * Wrap --help to 120 characters rather than 100 characters
* Filter-out nodes.json (#7716) * Filter-out nodes.json * network: sort node table nodes by failure ratio * network: fix node table tests * network: fit node failure percentage into buckets of 5% * network: consider number of attempts in sorting of node table * network: fix node table grumbles * Fix client not being dropped on shutdown (#7695) * parity: wait for client to drop on shutdown * parity: fix grumbles in shutdown wait * parity: increase shutdown timeouts * Wrap --help output to 120 characters (#7626) * Update Clap dependency and remove workarounds * WIP * Remove line breaks in help messages for now * Multiple values can only be separated by commas (closes #7428) * Grumbles; refactor repeating code; add constant * Use a single Wrapper rather than allocate a new one for each call * Wrap --help to 120 characters rather than 100 characters
* Filter-out nodes.json (#7716) * Filter-out nodes.json * network: sort node table nodes by failure ratio * network: fix node table tests * network: fit node failure percentage into buckets of 5% * network: consider number of attempts in sorting of node table * network: fix node table grumbles * Fix client not being dropped on shutdown (#7695) * parity: wait for client to drop on shutdown * parity: fix grumbles in shutdown wait * parity: increase shutdown timeouts * Wrap --help output to 120 characters (#7626) * Update Clap dependency and remove workarounds * WIP * Remove line breaks in help messages for now * Multiple values can only be separated by commas (closes #7428) * Grumbles; refactor repeating code; add constant * Use a single Wrapper rather than allocate a new one for each call * Wrap --help to 120 characters rather than 100 characters
The output of --help will now wrap at 100 characters (or to the terminal size if it's smaller than 100 characters). I used textwrap and term_size, which are two libraries also used by Clap.
textwrap doesn't support correctly wrapping strings with line breaks, so for now I removed the line breaks in the few help messages that had some, and made a PR on textwrap to add support.
Also Clap fixed some bugs on their latest version (dependency version was bumped yesterday by Marek) and added support for global arguments now natively propagating up and down (so that they can be placed anywhere in the command), and so I removed the workaround I had used. The code is a bit simpler now.
Output of
parity --help
: https://gist.github.com/axelchalon/d2aa66d26e19ea8f5484150af1a2ea62Output of
parity export state --help
: https://gist.github.com/axelchalon/69d50f8406ede0354176b94c8939a192Closes #7428