From 35cf3442d760f14dbfde42a1bafe24502b4155b3 Mon Sep 17 00:00:00 2001 From: ysthakur <45539777+ysthakur@users.noreply.github.com> Date: Sat, 18 Nov 2023 05:05:24 -0500 Subject: [PATCH] fix: call completion function in generated zsh --- src/gen/zsh.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gen/zsh.rs b/src/gen/zsh.rs index 8027612..d2b7b7d 100644 --- a/src/gen/zsh.rs +++ b/src/gen/zsh.rs @@ -40,8 +40,9 @@ pub fn generate(cmd: &CommandInfo, out_dir: &Path) -> Result<()> { // TODO make option to not overwrite file let comp_name = format!("_{}", cmd.name); let mut res = Output::new(String::from("\t")); - res.writeln(format!("#compdef {comp_name} {}", cmd.name)); + res.writeln(format!("#compdef {}", cmd.name)); generate_fn(cmd, &mut res, &comp_name); + res.writeln(format!(r#"{comp_name} "$@""#)); fs::write(out_dir.join(format!("{comp_name}.zsh")), res.text())?; Ok(()) } @@ -57,12 +58,10 @@ fn generate_fn(cmd: &CommandInfo, out: &mut Output, fn_name: &str) { out.writeln(format!("function {fn_name} {{")); out.indent(); - if !cmd.subcommands.is_empty() { - out.writeln("local line"); - } if cmd.subcommands.is_empty() { out.write("_arguments"); } else { + out.writeln("local line"); out.write("_arguments -C"); }