mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 22:40:09 +01:00
fix: runtime typo candite from shell
This commit is contained in:
parent
8740d01f12
commit
5428a7182d
3 changed files with 16 additions and 11 deletions
|
|
@ -62,9 +62,13 @@ fn print_help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_version() {
|
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:");
|
println!("compile features:");
|
||||||
#[cfg(feature = "runtime-rules")] {
|
#[cfg(feature = "runtime-rules")]
|
||||||
|
{
|
||||||
println!(" - runtime-rules");
|
println!(" - runtime-rules");
|
||||||
}
|
}
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ pub fn command(suggest: &mut String, split_command: &Vec<String>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn typo(suggest: &mut String, split_command: &Vec<String>) {
|
pub fn typo(suggest: &mut String, split_command: &Vec<String>, shell: &str) {
|
||||||
while suggest.contains("{{typo") {
|
while suggest.contains("{{typo") {
|
||||||
let (placeholder, args) = eval_placeholder(suggest, "{{typo", "}}");
|
let (placeholder, args) = eval_placeholder(suggest, "{{typo", "}}");
|
||||||
|
|
||||||
|
|
@ -148,13 +148,14 @@ pub fn typo(suggest: &mut String, split_command: &Vec<String>) {
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
let command;
|
let command;
|
||||||
// if match_list[0].starts_with("eval_shell_command(") {
|
if match_list[0].starts_with("{{shell") {
|
||||||
// // FIXME
|
let function = match_list.join(",");
|
||||||
let match_list = match_list
|
let (_, args) = eval_placeholder(&function, "{{shell", "}}");
|
||||||
.iter()
|
let function = &function[args.to_owned()].trim_matches(|c| c == '(' || c == ')');
|
||||||
.map(|s| s.trim().to_string())
|
command = suggest_typo(&split_command[index], eval_shell_command(shell, function));
|
||||||
.collect::<Vec<String>>();
|
} else {
|
||||||
command = suggest_typo(&split_command[index], match_list);
|
command = suggest_typo(&split_command[index], match_list);
|
||||||
|
}
|
||||||
|
|
||||||
suggest.replace_range(placeholder, &command);
|
suggest.replace_range(placeholder, &command);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ fn eval_suggest(
|
||||||
replaces::err(&mut suggest, error_msg);
|
replaces::err(&mut suggest, error_msg);
|
||||||
replaces::command(&mut suggest, split_command);
|
replaces::command(&mut suggest, split_command);
|
||||||
replaces::shell(&mut suggest, shell);
|
replaces::shell(&mut suggest, shell);
|
||||||
replaces::typo(&mut suggest, split_command);
|
replaces::typo(&mut suggest, split_command, shell);
|
||||||
|
|
||||||
Some(suggest)
|
Some(suggest)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue