sd: man page rendering is broken, resulting in broken examples
broken examples on man page as rendered in bash on macOS:
Regex use. Let's trim some trailing whitespace
$ echo 'lorem ipsum 23 ' | sd '' ''
lorem ipsum 23
Indexed capture groups
$ echo 'cargo +nightly watch' | sd '(0(24
cmd: cargo, channel: nightly, subcmd: watch
Named capture groups
$ echo "123.45" | sd '(?P<dollars>+).(?P<cents>+)' '$dollars dollars and $cents cents'
123 dollars and 45 cents
Same examples from README:
- Basic regex use - let’s trim some trailing whitespace
> echo 'lorem ipsum 23 ' | sd '\s+$' '' lorem ipsum 23
- Capture groups
Indexed capture groups:
> echo 'cargo +nightly watch' | sd '(\w+)\s+\+(\w+)\s+(\w+)' 'cmd: > $1, channel: $2, subcmd: $3' cmd: cargo, channel: nightly, subcmd: watchNamed capture groups:
> echo "123.45" | sd '(?P<dollars>\d+)\.(?P<cents>\d+)' '$dollars > dollars and $cents cents' 123 dollars and 45 cents
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 15 (5 by maintainers)
You already
include!ed../../src/cli.rs, that’s one thing. But clap reads the current Cargo.toml, which has the namextask, so you gotta alsocmd.name("sd").Reading (the top level) Cargo.toml is required to get the version.
(Sorry my hand went faster than brain)
Since this project already uses
clapfor the CLI arg parsing it would make sense to drop both the custom completions and the man page code from the repository and have it generated at build time byclap_completeandclap_mangenrespectively. These crates can be triggered just frombuild.rsso they don’t have to be baked into the final binary but can generate fresh up to date completions and man pages at build time so they never get out of sync. This is probably something I could contribute if the project is willing to accept it. Additionally if the project is interested I could addautotoolsplumbing so that all the unix-y bits like completions and man pages would get installed to the correct places if installed with./configure && make install. This would not hinder installation of the bare binary withcargo install, but for those that chose to use the autotools build method would result in not just the binary but the supporting files as well being installed to the correct places. Far an example of this being done (completions, man pages, & autotools install) you can see mygit-warp-timeproject.