cli zsh completions nit
This commit is contained in:
@@ -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 {
|
||||
|
||||
13
cli/test_completions4.ts
Normal file
13
cli/test_completions4.ts
Normal file
@@ -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();
|
||||
});
|
||||
Reference in New Issue
Block a user