Skip to content

Commit

Permalink
fix: update the test for fuzzy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Nov 13, 2023
1 parent 99e37cc commit c0e447f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions argh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ impl<'a> ParseStructOptions<'a> {
unrecognized_argument(
arg,
self.arg_to_slot,
&vec!["--help".to_owned(), "help".to_owned()],
&["--help".to_owned(), "help".to_owned()],
)
})?;

Expand Down Expand Up @@ -1017,11 +1017,11 @@ fn unrecognized_argument(
.collect::<Vec<&str>>();

if available.is_empty() {
return format!("Unrecognized argument: \"{}\"", given);
return format!("Unrecognized argument: \"{}\"\n", given);
}

let suggestions = fuzzy_search_best_n(given, &available, 1);
format!("Unrecognized argument: \"{}\". Did you mean \"{}\"?", given, suggestions[0].0)
format!("Unrecognized argument: \"{}\". Did you mean \"{}\"?\n", given, suggestions[0].0)
}

// `--` or `-` options, including a mutable reference to their value.
Expand Down
2 changes: 1 addition & 1 deletion argh/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ mod fuchsia_commandline_tools_rubric {

let e = OneOption::from_args(&["cmdname"], &["--foo=bar"])
.expect_err("Parsing option value using `=` should fail");
assert_eq!(e.output, "Unrecognized argument: --foo=bar\n");
assert_eq!(e.output, "Unrecognized argument: \"--foo=bar\". Did you mean \"--foo\"?\n");
assert!(e.status.is_err());
}

Expand Down

0 comments on commit c0e447f

Please sign in to comment.