From f0b7c96d04a9d71f969e9fa930f427053f40b46e Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 23 Feb 2026 09:09:16 +0000 Subject: [PATCH] cli zsh completions nit --- cli/src/main.ts | 17 +++++++++++++++-- cli/test_completions4.ts | 13 +++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 cli/test_completions4.ts diff --git a/cli/src/main.ts b/cli/src/main.ts index 730e0574d2..64ceb67b2d 100644 --- a/cli/src/main.ts +++ b/cli/src/main.ts @@ -1,5 +1,5 @@ import { Command } from "@cliffy/command"; -import { CompletionsCommand } from "@cliffy/command/completions"; +import { generateShellCompletions } from "@cliffy/command/completions"; import { UpgradeCommand } from "@cliffy/command/upgrade"; import * as log from "./core/log.ts"; @@ -172,7 +172,20 @@ const command = new Command() ); }) ) - .command("completions", new CompletionsCommand()); + .command( + "completions", + new Command() + .description("Generate shell completions.") + .command("bash", new Command().description("Generate bash completions.").action(() => { + process.stdout.write(generateShellCompletions(command, "bash") + "\n"); + })) + .command("zsh", new Command().description("Generate zsh completions.").action(() => { + process.stdout.write(generateShellCompletions(command, "zsh") + "\n"); + })) + .command("fish", new Command().description("Generate fish completions.").action(() => { + process.stdout.write(generateShellCompletions(command, "fish") + "\n"); + })) + ); async function main() { try { diff --git a/cli/test_completions4.ts b/cli/test_completions4.ts new file mode 100644 index 0000000000..77f60959f2 --- /dev/null +++ b/cli/test_completions4.ts @@ -0,0 +1,13 @@ +import { Command } from "@cliffy/command"; +import { ZshCompletionsGenerator } from "@cliffy/command/completions/_zsh_completions_generator"; +const { default: command } = await import("./src/main.ts"); + +// Generate completions manually +const output = ZshCompletionsGenerator.generate("wmill", command); +console.error(`output length: ${output.length}`); + +// Write using process.stdout.write with callback +process.stdout.write(output + "\n", () => { + console.error("write callback called"); + process.stdin.destroy(); +});