From 51b28ed0b0ec9d8d737f4c196210093336d955e0 Mon Sep 17 00:00:00 2001 From: merkrafter Date: Sun, 7 Nov 2021 22:10:21 +0100 Subject: [PATCH] Allow hex numbers for --block-size --- src/bin/hexyl.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index da4f324..76378df 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -147,6 +147,15 @@ fn run() -> Result<(), AnyhowError> { let block_size = matches .value_of("block_size") .map(|bs| { + if bs.starts_with(HEX_PREFIX) { + let n = &bs[HEX_PREFIX.len()..]; + return i64::from_str_radix(n, 16) + .map_err(|_| anyhow!("could not parse block size argument as hex number")) + .and_then(|x| { + PositiveI64::new(x) + .ok_or_else(|| anyhow!("block size argument must be positive")) + }); + } let (num, unit) = extract_num_and_unit_from(bs)?; if let Unit::Block { custom_size: _ } = unit { return Err(anyhow!(