fix: broken rules for new nushell version

This commit is contained in:
iff 2024-11-18 13:38:21 +01:00
parent 8f9aac6bdc
commit a71486e956
3 changed files with 8 additions and 3 deletions

View file

@ -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]}} '''
]

View file

@ -142,6 +142,7 @@ fn eval_condition(
"min_length" => split_command.len() >= arg.parse::<usize>().unwrap(),
"length" => split_command.len() == arg.parse::<usize>().unwrap(),
"max_length" => split_command.len() <= arg.parse::<usize>().unwrap() + 1,
"shell" => shell == arg,
_ => unreachable!("Unknown condition when evaluation condition: {}", condition),
}
}

View file

@ -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<String> {
#[allow(clippy::single_match)]
match shell {
"nushell" => Some(cd_dir),
"nu" => Some(cd_dir),
_ => Some(format!("cd {}", cd_dir)),
}
}