Skip to content

Commit 8f90cdf

Browse files
author
Gunter Schmidt
committed
Revert accidental commit
1 parent da517bb commit 8f90cdf

3 files changed

Lines changed: 2 additions & 45 deletions

File tree

src/uucore/locales/en-US.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ clap-error-missing-required-arguments = { $error_word }: the following required
1919
clap-error-possible-values = possible values
2020
clap-error-help-suggestion = For more information, try '{ $command } --help'.
2121
common-help-suggestion = For more information, try '--help'.
22-
# For clap_localization
23-
clap-error-ambiguous-argument=Error: Argument '{ $arg }' is ambiguous.
24-
Did you mean one of these?
2522
2623
# Common help text patterns
2724
help-flag-help = Print help information

src/uucore/locales/fr-FR.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ clap-error-missing-required-arguments = { $error_word } : les arguments requis s
1919
clap-error-possible-values = valeurs possibles
2020
clap-error-help-suggestion = Pour plus d'informations, essayez '{ $command } --help'.
2121
common-help-suggestion = Pour plus d'informations, essayez '--help'.
22-
# For clap_localization
23-
clap-error-ambiguous-argument=Error: L'argument '{ $arg }' est ambigu.
24-
Tu parlais d'un de ceux-ci?
2522
2623
# Modèles de texte d'aide communs
2724
help-flag-help = Afficher les informations d'aide

src/uucore/src/lib/mods/clap_localization.rs

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -432,55 +432,18 @@ where
432432
/// let result = handle_clap_result_with_exit_code(cmd, args, 125);
433433
/// ```
434434
pub fn handle_clap_result_with_exit_code<I, T>(
435-
mut cmd: Command,
435+
cmd: Command,
436436
itr: I,
437437
exit_code: i32,
438438
) -> UResult<ArgMatches>
439439
where
440440
I: IntoIterator<Item = T>,
441441
T: Into<OsString> + Clone,
442442
{
443-
// cloning args for double use in error case
444-
let args = itr.into_iter().collect::<Vec<T>>();
445-
let itr = args.clone();
446-
// using mut to avoid cloning cmd
447-
cmd.try_get_matches_from_mut(itr).map_err(|e| {
443+
cmd.try_get_matches_from(itr).map_err(|e| {
448444
if e.exit_code() == 0 {
449445
e.into() // Preserve help/version
450446
} else {
451-
if e.kind() == ErrorKind::UnknownArgument || e.kind() == ErrorKind::InvalidSubcommand {
452-
// find ambiguous options
453-
// Find the string the user actually typed (e.g., "--de")
454-
// for arg in &itr {}
455-
let args_str: Vec<String> = args
456-
.into_iter()
457-
.map(|t| {
458-
let o: OsString = t.into();
459-
o.to_string_lossy().to_string()
460-
})
461-
.collect();
462-
if let Some(provided) = args_str.iter().find(|a| a.starts_with("--")) {
463-
let search_term = provided.trim_start_matches("--");
464-
465-
// Manually filter all defined long arguments
466-
let mut matches: Vec<_> = cmd
467-
.get_arguments()
468-
.filter_map(|arg| arg.get_long())
469-
.filter(|l| l.starts_with(search_term))
470-
.collect();
471-
472-
if matches.len() > 1 {
473-
let mut msg =
474-
translate!("clap-error-ambiguous-argument", "arg" => provided);
475-
matches.sort();
476-
for m in matches {
477-
msg.push_str(&format!("\n --{}", m));
478-
}
479-
return USimpleError::new(exit_code, msg);
480-
}
481-
}
482-
}
483-
484447
let formatter = ErrorFormatter::new(crate::util_name());
485448
let code = formatter.print_error(&e, exit_code);
486449
USimpleError::new(code, "")

0 commit comments

Comments
 (0)