mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-28 08:05:52 +00:00
Allow hex numbers for --block-size
This commit is contained in:
1 parent
825100c6d6
commit
51b28ed0b0
1 file changed
+9
@@ -147,6 +147,15 @@ fn run() -> Result<(), AnyhowError> {
|
|||||||
let block_size = matches
|
let block_size = matches
|
||||||
.value_of("block_size")
|
.value_of("block_size")
|
||||||
.map(|bs| {
|
.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)?;
|
let (num, unit) = extract_num_and_unit_from(bs)?;
|
||||||
if let Unit::Block { custom_size: _ } = unit {
|
if let Unit::Block { custom_size: _ } = unit {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
|
|||||||
Reference in new issue
Block a user