Refactor Some(length) and change --c/-c to --bytes/-c

This commit is contained in:
selfup authored and David Peter committed 2019-02-05 23:15:43 +01:00
1 parent c8e65d7528
commit 8725f8cd25
1 file changed
+4 -9
+4 -9
View File
@@ -235,9 +235,9 @@ fn run() -> Result<(), Box<::std::error::Error>> {
.help("Read only N bytes from the input"), .help("Read only N bytes from the input"),
) )
.arg( .arg(
Arg::with_name("c") Arg::with_name("bytes")
.short("c") .short("c")
.long("c") .long("bytes")
.takes_value(true) .takes_value(true)
.hidden(true), .hidden(true),
) )
@@ -263,14 +263,9 @@ fn run() -> Result<(), Box<::std::error::Error>> {
None => Box::new(stdin.lock()), None => Box::new(stdin.lock()),
}; };
if let Some(length) = matches let length_arg = matches.value_of("length").or(matches.value_of("bytes"));
.value_of("length")
.and_then(|n| n.parse::<u64>().ok())
{
reader = Box::new(reader.take(length));
}
if let Some(length) = matches.value_of("c").and_then(|n| n.parse::<u64>().ok()) { if let Some(length) = length_arg.and_then(|n| n.parse::<u64>().ok()) {
reader = Box::new(reader.take(length)); reader = Box::new(reader.take(length));
} }