sharkdp / hexyl

A command-line hex viewer
Apache License 2.0
8.92k stars 227 forks source link

Rewrite CLI using the derive API #225

Open sorairolake opened 3 days ago

sorairolake commented 3 days ago

Change to use clap's derive API to implement CLI. Probably, this should not change the behavior.

However, the help message is changed to:

sharkdp commented 3 days ago

Thank you very much for your contribution!

When -h is specified, only the first sentence of the help message for each option is printed.

This is something we came across in fd as well. This is how we fixed it: https://github.com/sharkdp/fd/pull/1067/commits/36ee44a3f6ca6cbe06229ed7a133a501fb28d8ab

sorairolake commented 2 days ago

Changed so that even if -h is specified, other than the first sentence will also be printed.

Difference of the short help output between 16cc5d9 and f8b87cc ```diff A command-line hex viewer Usage: hexyl [OPTIONS] [FILE] Arguments: - [FILE] The file to display. If no FILE argument is given, read from STDIN. + [FILE] The file to display. If no FILE argument is given, read from STDIN Options: -n, --length Only read N bytes from the input. The N argument can also include a unit with a decimal prefix (kB, MB, ..) or binary prefix (kiB, MiB, ..), or can be specified using a hex number. The short option '-l' can be used as an alias. Examples: --length=64, --length=4KiB, --length=0xff - -c, --bytes An alias for -n/--length + [aliases: bytes] [short aliases: c] -s, --skip Skip the first N bytes of the input. The N argument can - also include a unit (see `--length` for details) + also include a unit (see `--length` for details). A negative value is valid and will seek from the end of the file. - --block-size Sets the size of the `block` unit to SIZE (default is - 512). - Examples: --block-size=1024, --block-size=4kB + --block-size Sets the size of the `block` unit to SIZE. + Examples: --block-size=1024, --block-size=4kB [default: + 512] -v, --no-squeezing Displays all input data. Otherwise any number of groups of output lines which would be identical to the preceding group of lines, are replaced with a line - comprised of a single asterisk. - --color When to use colors. The 'auto' mode only displays colors - if the output goes to an interactive terminal. 'force' - can be used to override the NO_COLOR environment - variable. [default: always] [possible values: always, - auto, never, force] - --border