-
Notifications
You must be signed in to change notification settings - Fork 352
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
wrap --help output #1440
base: main
Are you sure you want to change the base?
wrap --help output #1440
Conversation
Thanks! I tried this out and it seems like a good improvement to me. (Tangential: Ultimately I feel that the lengthy man-page style output should be sent into a pager.) |
Now that |
(There's a formatter error here.) |
The fmt is fixed, but sending the output into a pager via |
Hm. Is it the |
Use new, smaller PagerCfg instead of the full Config, as for pager output only 3 variables are relevant. oneshot_write() can be used to write paginated output, usually before exiting.
Set clap option `max_term_width`, so the help output is by default as wide as the terminal or this max value. Then manually wrap the `after_long_help()` text (only on demand) to the same width using `textwrap`. Also use matching ansi codes in this section. The help output is now paginated if output is to a terminal. All code paths flow back to main() so an invoked pager is properly waited for (by the OutputType drop impl).
src/cli.rs
Outdated
{ | ||
write!(&mut writer, "{}", help.ansi()).unwrap(); | ||
// dtor? | ||
} |
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.
It wasn't the writer drop impl/destructor but the one of output_type!
Now with pager support, even listens to The Oh and I found |
Set clap option
max_term_width
, so the help output is by default as wide as the terminal or this max value. Then manually wrap theafter_long_help()
text (only on demand) to the same width usingtextwrap
. Also use matching ansi codes in this section.Another try to improve deltas --help output, and I finally can use textwrap! But now
--version
and--help
is handled manually. Another possibility would be to manually construct the pieces of clapsStyledStr
(...which is returned fromrender_help()
and according todbg!()
different from the simple String wrapper?render_help() = StyledStr { pieces: [ (None, "A viewer for git and diff output",), (..)] }
).CC @tjquillan @nickelc @FGasper