return an error if there are more name options than commands

This commit is contained in:
Stéphane Campinas authored and David Peter committed 2020-10-15 22:42:44 +02:00
1 parent 71a47c0566
commit 25f8129212
2 files changed
+10

No files matched your search

+6
View File
@@ -130,6 +130,12 @@ fn build_hyperfine_options(matches: &ArgMatches<'_>) -> Result<HyperfineOptions,
options.names = matches
.values_of("command-name")
.map(|values| values.map(String::from).collect::<Vec<String>>());
if let Some(ref names) = options.names {
let command_strings = matches.values_of("command").unwrap();
if names.len() > command_strings.len() {
return Err(OptionsError::TooManyCommandNames(command_strings.len()));
}
}
options.preparation_command = matches
.values_of("prepare")