From a71486e956c7cad02c745ec03146cd5feac57bd2 Mon Sep 17 00:00:00 2001 From: iff Date: Mon, 18 Nov 2024 13:38:21 +0100 Subject: [PATCH] fix: broken rules for new nushell version --- rules/cd.toml | 4 +++- src/runtime_rules.rs | 1 + src/shell.rs | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rules/cd.toml b/rules/cd.toml index b6b6b75..6510147 100644 --- a/rules/cd.toml +++ b/rules/cd.toml @@ -7,6 +7,7 @@ pattern = [ ] suggest = [ ''' +#[!shell(nu)] mkdir --parents {{command[1]}} && \ cd {{command[1]}} ''' ] @@ -17,5 +18,6 @@ pattern = [ ] suggest = [ ''' -mkdir {{command[1]}} ''' +mkdir {{command[1]}} and \ +cd {{command[1]}} ''' ] diff --git a/src/runtime_rules.rs b/src/runtime_rules.rs index 13e873c..57b7b12 100644 --- a/src/runtime_rules.rs +++ b/src/runtime_rules.rs @@ -142,6 +142,7 @@ fn eval_condition( "min_length" => split_command.len() >= arg.parse::().unwrap(), "length" => split_command.len() == arg.parse::().unwrap(), "max_length" => split_command.len() <= arg.parse::().unwrap() + 1, + "shell" => shell == arg, _ => unreachable!("Unknown condition when evaluation condition: {}", condition), } } diff --git a/src/shell.rs b/src/shell.rs index 1017777..29d377a 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -249,9 +249,11 @@ end pub fn shell_syntax(shell: &str, command: &mut String) { #[allow(clippy::single_match)] + eprintln!("command: {}", command); match shell { - "nushell" => { + "nu" => { *command = command.replace(" && ", " and "); + eprintln!("command: {}", command); } _ => {} } @@ -276,7 +278,7 @@ pub fn shell_evaluated_commands(shell: &str, command: &str) -> Option { #[allow(clippy::single_match)] match shell { - "nushell" => Some(cd_dir), + "nu" => Some(cd_dir), _ => Some(format!("cd {}", cd_dir)), } }