Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions argh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ trybuild = "1.0.63"
default = ["help", "serde"]
help = ["argh_derive/help"]
serde = ["argh_shared/serde"]
fuzzy_search = ["dep:rust-fuzzy-search"]
6 changes: 3 additions & 3 deletions argh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ pub type SubCommandInfo = argh_shared::SubCommandInfo<'static>;

pub use argh_shared::{ErrorCodeInfo, FlagInfo, FlagInfoKind, Optionality, PositionalInfo};

#[cfg(feature = "rust-fuzzy-search")]
#[cfg(feature = "fuzzy_search")]
use rust_fuzzy_search::fuzzy_search_best_n;

/// Structured information about the command line arguments.
Expand Down Expand Up @@ -1040,7 +1040,7 @@ fn unrecognized_argument(
return format!("Unrecognized argument: \"{}\"\n", given);
}

#[cfg(feature = "rust-fuzzy-search")]
#[cfg(feature = "fuzzy_search")]
{
let suggestions = fuzzy_search_best_n(given, &available, 1);
return format!(
Expand All @@ -1049,7 +1049,7 @@ fn unrecognized_argument(
);
}

#[cfg(not(feature = "rust-fuzzy-search"))]
#[cfg(not(feature = "fuzzy_search"))]
["Unrecognized argument: ", given, "\n"].concat()
}

Expand Down
4 changes: 2 additions & 2 deletions argh/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,9 @@ mod fuchsia_commandline_tools_rubric {

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