Cleaned up terminal-width validation even more

This commit is contained in:
Ethan P 2019-05-10 14:27:13 -07:00 committed by David Peter
parent 89fcbb2b15
commit 7ef0fe091d
1 changed files with 1 additions and 7 deletions

View File

@ -334,13 +334,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.validator( .validator(
|t| { |t| {
let is_offset = t.starts_with('+') || t.starts_with('-'); let is_offset = t.starts_with('+') || t.starts_with('-');
let num = if is_offset { t.parse::<i32>()
t.chars().skip(1).collect()
} else {
t
};
num.parse::<u32>()
.map_err(|_e| "must be an offset or number") .map_err(|_e| "must be an offset or number")
.and_then(|v| if v == 0 && !is_offset { .and_then(|v| if v == 0 && !is_offset {
Err("terminal width cannot be zero".into()) Err("terminal width cannot be zero".into())