Skip to main content

suggest_subcommand

Function suggest_subcommand 

Source
pub fn suggest_subcommand(input: &str) -> Option<String>
Expand description

Suggest the closest known subcommand for an unknown input string.

Uses Jaro-Winkler similarity. Returns Some(suggestion) if any known subcommand is more than 70% similar, or None if no close match exists.

§Examples

use openlatch_client::cli::suggest_subcommand;
assert_eq!(suggest_subcommand("stats"), Some("status".to_string()));
assert_eq!(suggest_subcommand("xyz"), None);