mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-26 20:16:31 +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
+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"));
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user