delta
delta copied to clipboard
wrap --help output
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.
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 claps StyledStr (...which is returned from render_help() and according to dbg!() different from the simple String wrapper? render_help() = StyledStr { pieces: [ (None, "A viewer for git and diff output",), (..)] } ).
CC @tjquillan @nickelc @FGasper
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 --help is handled manually, piping the output into less -R is easy. And clap doesn't seen to support a pager currently.
(There's a formatter error here.)
The fmt is fixed, but sending the output into a pager via OutputType::from_mode (now using a lighter PagerCfg) doesn't work, the default pager less just quits after the first page. PagingMode::Always doesn't help, and a default DeltaEnv::init() works fine for the normal delta. However DELTA_PAGER="cat" does display the entire output. strace shows less is started as "/usr/bin/less", ["less", "--RAW-CONTROL-CHARS"] as expected, what am I missing?
Hm. Is it the LESS environment variable supplying additional arguments?
Now with pager support, even listens to PAGER etc. env vars for configuration (but not --paging never).
The full---help-output.md markdown is a bit out of sync, but could be generated from then ansi --help output itself. However the one tool for that, term2md, currently removes leading whitespace.
Oh and I found --show-themes is/was already broken.
This one has conflicts for us to resolve. Sorry for letting it drag on.
The full help output has to be regenerated (some ansi2md util would help), and I have to check that the big moved textblock in cli.rs is still correct.
Also fixed the rust 1.80 build, note the Cargo.* changes. FTR, the build for the time crate was:
--> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.31/src/format_description/parse/mod.rs:83:9
|
83 | let items = format_items
| ^^^^^
...
86 | Ok(items.into())
| ---- type must be known at this point
|
help: consider giving `items` an explicit type, where the placeholders `_` are specified
|
83 | let items: Box<_> = format_items
| ++++++++
(Currently, v0.17.0, cargo install delta still works with 1.80, only --locked fails.)
I've approved this one already; please merge at will!
I think this PR accidentally caused delta -h lines to be wrapped; I've opened https://github.com/dandavison/delta/issues/1795.
@dandavison would it be possible to cut a new release with this Rust 1.80 fix? It would make it possible to upgrade delta in nixpkgs (https://github.com/NixOS/nixpkgs/issues/332957)
@ofalvai will do! I'll ping here when it's done.