diff options
author | David Peter <mail@david-peter.de> | 2023-04-25 09:12:26 +0200 |
---|---|---|
committer | David Peter <david.peter@bosch.com> | 2023-04-25 09:12:26 +0200 |
commit | 9be018fbb9f5d7be00f05933714bb78f0a7f6ca8 (patch) | |
tree | ded97c1853a0989f616f0477b2b32786012af4a7 /src | |
parent | cba717b7832c51e0196c96160cab09744b708b0a (diff) |
Add -e alias for --endianness=little
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/hexyl.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index cc7fe8f..f59640d 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -190,10 +190,19 @@ fn run() -> Result<()> { .help( "Whether to print out groups in little-endian or big-endian \ format. This option only has an effect if the '--group-size' \ - is larger than 1.", + is larger than 1. '-e' can be used as an alias for \ + '--endianness=little'.", ), ) .arg( + Arg::new("little_endian_format") + .short('e') + .action(ArgAction::SetTrue) + .overrides_with("endianness") + .hide(true) + .help("An alias for '--endianness=little'."), + ) + .arg( Arg::new("base") .short('b') .long("base") @@ -440,9 +449,14 @@ fn run() -> Result<()> { ) }; - let endianness = match matches.get_one::<String>("endianness").map(String::as_ref) { - Some("little") => Endianness::Little, - Some("big") => Endianness::Big, + let little_endian_format = *matches.get_one::<bool>("little_endian_format").unwrap(); + let endianness = matches.get_one::<String>("endianness"); + let endianness = match ( + endianness.map(|s| s.as_ref()).unwrap(), + little_endian_format, + ) { + (_, true) | ("little", _) => Endianness::Little, + ("big", _) => Endianness::Big, _ => unreachable!(), }; let stdout = io::stdout(); |