mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-13 06:50:09 +01:00
refactor: split runtime rules into module
This commit is contained in:
parent
000b50c211
commit
5aebf867c1
20 changed files with 514 additions and 249 deletions
|
|
@ -184,7 +184,7 @@ fn parse_conditions(suggest: &str) -> (String, Vec<TokenStream2>) {
|
|||
|
||||
fn eval_condition(condition: &str, arg: &str) -> TokenStream2 {
|
||||
match condition {
|
||||
"executable" => quote! {data.has_executable(#arg)},
|
||||
"executable" => quote! {executables.contains(&#arg.to_string())},
|
||||
"err_contains" => quote! {error_msg.contains(#arg)},
|
||||
"cmd_contains" => quote! {last_command.contains(#arg)},
|
||||
"min_length" => quote! {(split.len() >= #arg.parse::<usize>().unwrap())},
|
||||
|
|
@ -215,6 +215,6 @@ fn eval_suggest(suggest: &str) -> TokenStream2 {
|
|||
|
||||
quote! {
|
||||
#(#opt_list)*
|
||||
data.add_candidate(&format!{#suggest, #(#replace_list),*});
|
||||
candidates.push(format!{#suggest, #(#replace_list),*});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue