X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/a411a19d502a2ee8ce16c0cd7f447dac3293cee4..b2f318323ffed782b90237e38015d65638848d3d:/src/lib.rs diff --git a/src/lib.rs b/src/lib.rs index af582d4..d974461 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,11 @@ impl Config { .map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, e))?; } else if let Some(col) = cmd.strip_prefix("col ") { self.static_columns.push(col.to_owned()); + } else { + return Err(std::io::Error::new( + std::io::ErrorKind::InvalidInput, + format!("Unknown command: {cmd}"), + )); } Ok(()) } @@ -518,6 +523,10 @@ mod tests { vec!["foo".to_owned()] ); + let bad_command = read_config(&b"!no such command"[..]); + assert!(bad_command.is_err()); + assert!(format!("{bad_command:?}").contains("Unknown command")); + let bad_num = read_config(&b"!col_threshold foo"[..]); assert!(bad_num.is_err()); assert!(format!("{bad_num:?}").contains("Parse"));