mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-30 09:05:54 +00:00
Allow passing length in hex with 0x notation
This commit is contained in:
1 parent
c6c4dd416e
commit
6a848b14f8
2 files changed
+11
-1
No files matched your search
Generated
+2
@@ -1,3 +1,5 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ansi_term"
|
name = "ansi_term"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
|||||||
+9
-1
@@ -274,7 +274,15 @@ fn run() -> Result<(), Box<::std::error::Error>> {
|
|||||||
|
|
||||||
let length_arg = matches.value_of("length").or(matches.value_of("bytes"));
|
let length_arg = matches.value_of("length").or(matches.value_of("bytes"));
|
||||||
|
|
||||||
if let Some(length) = length_arg.and_then(|n| n.parse::<u64>().ok()) {
|
if let Some(length) = length_arg.and_then(|n| {
|
||||||
|
if n.starts_with("0x") {
|
||||||
|
u64::from_str_radix(n.trim_start_matches("0x"), 16).ok()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
n.parse::<u64>().ok()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
{
|
||||||
reader = Box::new(reader.take(length));
|
reader = Box::new(reader.take(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user