-
-
Notifications
You must be signed in to change notification settings - Fork 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
Automatically use NextLineHelp with long option names/values #597
Comments
I think the base has been laid to do this, where the flags+spaces > longest word in the help string. This should be an easy add now. @joshtriplett is there another metric you'd use to determine when a flag/option is "too long" and should trigger use of the next line? |
@kbknapp In terms of heuristics, I'd suggest checking if the name of an option, its argument, and the needed whitespace would take up more than 25% of the terminal width. For an 80-character terminal, that'd be 20 characters, which seems reasonable. Actually, somewhere around 20 characters is probably a reasonable upper limit in general, since even on a wider terminal you don't want an excessive amount of whitespace on other options caused by a single long option name. Perhaps "longer than 25% of the terminal width or 24 characters, whichever is smaller"? |
@joshtriplett I did some checking just based on random Rust CLI, and on 80 column terminals quite a significant ratio of help lines would end up on the next line, even though the entirety of their help text fits. So I thought, perhaps only those who's help text is greater than 75% when the flags/options values, etc. is greater than 25%, which works, but still ends up (IMO) jumping to the next line too early. So what I'd like to do, just as a start since we can change this later based on feedback and just aesthetics is to use 40% as the margin, and only when the help text exceeds the remaining 60%. Perhaps even later we could make this editable 😜 |
@kbknapp The heuristic should definitely include "some help texts" (not just the current one) would wrap. 40% seems worth trying. And I'd rather see a sensible default heuristic than configurability. :) |
@joshtriplett So I just finished implementing this, and ended up going with something far closer to what you originally stated. It moves the help text to the next line only if it doesn't fit, no matter the length of the flags/options/spaces/values. The exception to this is, is when the flags/options/spaces/values is less than 25%, at which point it just wraps normally as it would have. Of the tests I've run, this seems to be the least alerting and most natural. i.e. at 70 width, the
|
That sounds good to me. I'd still love to see the paragraph aligned with the help text of the other options, though. But that's a separate issue (#587). |
Yeah, I'll have to play with it some more since those two paragraphs are aligned separately...so we'll see as I get more time to tinker! 👍 |
@kbknapp Because one is under FLAGS and the other is under OPTIONS? For a first pass, if it's easier, it'd be fine if all the FLAGS had a single indent level for help and all the OPTIONS had a single indent level for help, even if they didn't have the same one. I use |
…hen term width is determined to be too small, or help text is too long Now `clap` will check if it should automatically place long help messages on the next line after the flag/option. This is determined by checking to see if the space taken by flag/option plus spaces and values doesn't leave enough room for the entirety of the help message, with the single exception of of if the flag/option/spaces/values is less than 25% of the width. Closes #597
Yeah they're determined independently...unless you use |
Based on discussion in #587 .
Clap should limit the maximum width of the option name/value column, and automatically use NextLineHelp otherwise.
The text was updated successfully, but these errors were encountered: