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
optionally wrap help lines at less than terminal width #1469
Comments
From what I understood when the issue was created, they are asking some kind of runtime max width specifying capability. |
You are right, I missed this part:
If there is a standard env variable across apps, I can see reading it, like https://no-color.org/, otherwise, I think this is best left to the app developer to define and read the variable, setting let max_width = std::env::var("FOO_MAX_WIDTH")
.and_then(|s| s.parse::<usize>().ok())
.unwrap_or(100);
app
.max_term_width(max_width) The developer can read this and then apply it to other areas of their app as well. Any reason for us to own this behavior in clap? |
The only scenario I can think of is allow the user to specify the width via an arg. But this might be niche? |
I've noted the way for users to directly do this in the Issue description. I think for now we should consider that the recommended solution. If there are concerns with this, feel free to speak up! It will help us know whether to re-evaluate. |
Maintainer's notes:
Workaround
Rust Version
Affected Version of clap
Bug or Feature Request Summary
I have just browsed through quite some
man
pages (mostlygit help cmd
) and clap-generated long help outputs (bat
,fd
, some of my own tools). While doing that, I have noticed thatman
wraps paragraphs not at terminal width but less than that. This can be considered a follow-up to #428 and #451.I think, I have noticed this because I have been looking at
man
pages for quite some time and, while the clap-generated long help output (--help
) looks very similar to aman
page (thank you for that, it's awesome!), it sometimes looked a bit weird (to me). I finally noticed what was bugging me and it is the wrapping.In my opinion (yes, subjectively, I'm getting to that), it is more readable to wrap at less than terminal width. Maybe you feel the same way. Even if you do not feel the same way, you might (objectively) consider for clap-generated long help output to emulate the behavior of
man
pages in this regard.It is subjective what looks best, to wrap at term width or to wrap at term width minus some value. Thus, objectively, this is not something that the CLI app developer should decide, but the user herself/himself. For this objective reason, I am suggesting to let the app user have the final say in this, not the developer as is done now. I suggest to add an environment variable that clap looks for, e.g. like in this
~/.bash_profile
snippet:Note: I tested how
man
wraps with different terminal sizes. On standard terminal of 80 x 24 the wrapping is at column 78, socolumns - 2
and with my usual terminal of 147 columns it's atcolumns - 4
. I guess, they decide somehow. I haven't looked at their code yet.The text was updated successfully, but these errors were encountered: