mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +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() {
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
let (placeholder, args) = eval_placeholder(suggest, "{{typo", "}}");
|
||||
|
||||
|
|
@ -148,13 +148,14 @@ pub fn typo(suggest: &mut String, split_command: &Vec<String>) {
|
|||
.collect::<Vec<String>>();
|
||||
|
||||
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::<Vec<String>>();
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue