Allow passing length in hex with 0x notation

This commit is contained in:
Mikaela Szekely authored and David Peter committed 2019-03-09 07:41:52 +01:00
1 parent c6c4dd416e
commit 6a848b14f8
2 files changed
+11 -1

No files matched your search

Generated
+2
View File
@@ -1,3 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "ansi_term"
version = "0.11.0"
+9 -1
View File
@@ -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));
}