Skip to content

Commit

Permalink
xsv: fix error message for invalid commands
Browse files Browse the repository at this point in the history
Fixes #138
  • Loading branch information
mintyplanet authored and BurntSushi committed Oct 2, 2018
1 parent 63ad0b3 commit c8c3484
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Please choose one of the following commands:",
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase")]
enum Command {
Cat,
Count,
Expand Down Expand Up @@ -167,6 +168,12 @@ impl Command {
let argv: Vec<_> = env::args().map(|v| v.to_owned()).collect();
let argv: Vec<_> = argv.iter().map(|s| &**s).collect();
let argv = &*argv;

if !argv[1].chars().all(char::is_lowercase) {
return Err(CliError::Other(format!(
"xsv expects commands in lowercase. Did you mean '{}'?",
argv[1].to_lowercase()).to_string()));
}
match self {
Command::Cat => cmd::cat::run(argv),
Command::Count => cmd::count::run(argv),
Expand Down

0 comments on commit c8c3484

Please sign in to comment.