diff --git a/src/args.rs b/src/args.rs index 76c000d..988f2ab 100644 --- a/src/args.rs +++ b/src/args.rs @@ -62,9 +62,13 @@ fn print_help() { } fn print_version() { - println!("version: {}", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")); + println!( + "version: {}", + option_env!("CARGO_PKG_VERSION").unwrap_or("unknown") + ); println!("compile features:"); - #[cfg(feature = "runtime-rules")] { + #[cfg(feature = "runtime-rules")] + { println!(" - runtime-rules"); } std::process::exit(0); diff --git a/src/replaces.rs b/src/replaces.rs index 9e179a1..c5350b2 100644 --- a/src/replaces.rs +++ b/src/replaces.rs @@ -84,7 +84,7 @@ pub fn command(suggest: &mut String, split_command: &Vec) { } } -pub fn typo(suggest: &mut String, split_command: &Vec) { +pub fn typo(suggest: &mut String, split_command: &Vec, shell: &str) { while suggest.contains("{{typo") { let (placeholder, args) = eval_placeholder(suggest, "{{typo", "}}"); @@ -148,13 +148,14 @@ pub fn typo(suggest: &mut String, split_command: &Vec) { .collect::>(); let command; - // if match_list[0].starts_with("eval_shell_command(") { - // // FIXME - let match_list = match_list - .iter() - .map(|s| s.trim().to_string()) - .collect::>(); - command = suggest_typo(&split_command[index], match_list); + if match_list[0].starts_with("{{shell") { + let function = match_list.join(","); + let (_, args) = eval_placeholder(&function, "{{shell", "}}"); + let function = &function[args.to_owned()].trim_matches(|c| c == '(' || c == ')'); + command = suggest_typo(&split_command[index], eval_shell_command(shell, function)); + } else { + command = suggest_typo(&split_command[index], match_list); + } suggest.replace_range(placeholder, &command); } diff --git a/src/runtime_rules.rs b/src/runtime_rules.rs index 17f5b21..18e5b09 100644 --- a/src/runtime_rules.rs +++ b/src/runtime_rules.rs @@ -170,7 +170,7 @@ fn eval_suggest( replaces::err(&mut suggest, error_msg); replaces::command(&mut suggest, split_command); replaces::shell(&mut suggest, shell); - replaces::typo(&mut suggest, split_command); + replaces::typo(&mut suggest, split_command, shell); Some(suggest) }