diff options
author | sharkdp <davidpeter@web.de> | 2020-06-07 14:37:17 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-06-07 15:12:35 +0200 |
commit | 3ca002638c0ba3779f8ee80cdfac617e14de8480 (patch) | |
tree | 5df861df27e27db6a603fb94ee804ab4c28a91be | |
parent | ccfceaf58c3f85cef269decbe107b3266e97a073 (diff) |
Improve help text
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | src/bin/hexyl.rs | 32 |
2 files changed, 24 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f033c70..eb8b32d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,8 @@ ## Features -- Added a new `--skip <N>` / `-s <N>` option to skip the first `N` bytes of the input, see #16, #88 - (Thanks to @Tarnadas, @MaxJohansen) -- The `--length`/`--bytes`/`--skip` options can now take units for their value argument, for example: +- A new `--skip <N>` / `-s <N>` option can be used to skip the first `N` bytes of the input, see #16, #88 (@Tarnadas, @MaxJohansen, @ErichDonGubler) +- The `--length`/`--bytes`/`--skip`/`--display-offset` options can now take units for their value argument, for example: ``` bash hexyl /dev/random --length=1KiB hexyl $(which hexyl) --skip=1MiB --length=10KiB diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 2f11cff..a9da17c 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -19,14 +19,21 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { .setting(AppSettings::UnifiedHelpMessage) .version(crate_version!()) .about(crate_description!()) - .arg(Arg::with_name("file").help("File to display")) + .arg( + Arg::with_name("FILE") + .help("The file to display. If no FILE argument is given, read from STDIN."), + ) .arg( Arg::with_name("length") .short("n") .long("length") .takes_value(true) .value_name("N") - .help("Read only N bytes from the input"), + .help( + "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, ..).\n\ + Examples: --length=64, --length=4KiB", + ), ) .arg( Arg::with_name("bytes") @@ -42,7 +49,10 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { .long("skip") .takes_value(true) .value_name("N") - .help("Skip first N bytes"), + .help( + "Skip the first N bytes of the input. The N argument can also include \ + a unit (see `--length` for details)", + ), ) .arg( Arg::with_name("block_size") @@ -50,8 +60,8 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { .takes_value(true) .value_name("SIZE") .help( - "Sets the size of the `block` unit to SIZE. Examples: \ - --block-size=1024, --block-size=4kB", + "Sets the size of the `block` unit to SIZE.\n\ + Examples: --block-size=1024, --block-size=4kB", ), ) .arg( @@ -68,7 +78,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { Arg::with_name("color") .long("color") .takes_value(true) - .value_name("when") + .value_name("WHEN") .possible_values(&["always", "auto", "never"]) .default_value("always") .help( @@ -80,24 +90,26 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { Arg::with_name("border") .long("border") .takes_value(true) + .value_name("STYLE") .possible_values(&["unicode", "ascii", "none"]) .default_value("unicode") - .help("Whether to draw a border with unicode or ASCII characters, or none at all"), + .help("Whether to draw a border with Unicode characters, ASCII characters, or none at all"), ) .arg( Arg::with_name("display_offset") .short("o") .long("display-offset") .takes_value(true) - .value_name("OFFSET") - .help("Add OFFSET to the displayed file position."), + .value_name("N") + .help("Add N bytes to the displayed file position. The N argument can also include \ + a unit (see `--length` for details)"), ); let matches = app.get_matches_safe()?; let stdin = io::stdin(); - let mut reader: Input = match matches.value_of("file") { + let mut reader: Input = match matches.value_of("FILE") { Some(filename) => Input::File(File::open(filename)?), None => Input::Stdin(stdin.lock()), }; |