diff --git a/libs/cli_parser/src/completions.rs b/libs/cli_parser/src/completions.rs index d8409f0c905441..5be3de8ed81416 100644 --- a/libs/cli_parser/src/completions.rs +++ b/libs/cli_parser/src/completions.rs @@ -136,6 +136,18 @@ fn zsh_description(help: &str) -> String { escaped } +/// Render a flag as a single-quoted zsh `_arguments` spec, including its short +/// form when it has one. +fn zsh_flag_spec(arg: &ArgDef, long: &str) -> String { + let desc = zsh_description(arg.help); + match arg.short { + Some(short) => { + format!("'(-{short} --{long})'{{-{short},--{long}}}'{desc}'") + } + None => format!("'--{long}{desc}'"), + } +} + fn generate_zsh(cmd: &CommandDef) -> Vec { let name = cmd.name; let mut out = String::new(); @@ -163,26 +175,41 @@ fn generate_zsh(cmd: &CommandDef) -> Vec { " )\n _describe -t commands 'deno commands' commands\n}\n\n", ); + // `deno [flags]