Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit c8c3484

Browse files
mintyplanetBurntSushi
authored andcommitted
xsv: fix error message for invalid commands
Fixes #138
1 parent 63ad0b3 commit c8c3484

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Please choose one of the following commands:",
138138
}
139139

140140
#[derive(Debug, Deserialize)]
141+
#[serde(rename_all = "lowercase")]
141142
enum Command {
142143
Cat,
143144
Count,
@@ -167,6 +168,12 @@ impl Command {
167168
let argv: Vec<_> = env::args().map(|v| v.to_owned()).collect();
168169
let argv: Vec<_> = argv.iter().map(|s| &**s).collect();
169170
let argv = &*argv;
171+
172+
if !argv[1].chars().all(char::is_lowercase) {
173+
return Err(CliError::Other(format!(
174+
"xsv expects commands in lowercase. Did you mean '{}'?",
175+
argv[1].to_lowercase()).to_string()));
176+
}
170177
match self {
171178
Command::Cat => cmd::cat::run(argv),
172179
Command::Count => cmd::count::run(argv),

0 commit comments

Comments
 (0)