on master help sign in
Cleaned up terminal-width validation slightly
89fcbb2Ethan P
src/clap_app.rs+3−3
@@ -333,8 +333,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
333 .hidden_short_help(true)
333 .hidden_short_help(true)
334 .validator(
334 .validator(
335 |t| {
335 |t| {
336− let sign = t.chars().next().unwrap();
336+ let is_offset = t.starts_with('+') || t.starts_with('-');
337− let num = if (sign == '+') || (sign == '-') {
337+ let num = if is_offset {
338 t.chars().skip(1).collect()
338 t.chars().skip(1).collect()
339 } else {
339 } else {
340 t
340 t
@@ -342,7 +342,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
342
342
343 num.parse::<u32>()
343 num.parse::<u32>()
344 .map_err(|_e| "must be an offset or number")
344 .map_err(|_e| "must be an offset or number")
345− .and_then(|v| if v == 0 && sign != '+' && sign != '-' {
345+ .and_then(|v| if v == 0 && !is_offset {
346 Err("terminal width cannot be zero".into())
346 Err("terminal width cannot be zero".into())
347 } else {
347 } else {
348 Ok(())
348 Ok(())