When I looked at the source code, I noticed an issue with the generated bash-complete.ts file:
#!/usr/bin/env node
import { proposeCompletions } from "@stricli/core";
import { buildContext } from "../context";
import { app } from "../app";
const inputs = process.argv.slice(3);
if (process.env["COMP_LINE"]?.endsWith(" ")) {
inputs.push("");
}
await proposeCompletions(app, inputs, buildContext(process));
I was able to get things working when I actually iterated over the completion set and wrote the results to stdout (separating each completion by a newline):
import { proposeCompletions } from "@stricli/core";
import process from "node:process";
import { cli } from "../cli/cli.ts";
import { buildContext } from "../context/context.ts";
const inputs = process.argv.slice(3);
if (process.env["COMP_LINE"]?.endsWith(" ")) {
inputs.push("");
}
const completions = await proposeCompletions(
cli,
inputs,
buildContext(process),
);
for (const completion of completions) {
process.stdout.write(`${completion.completion}\n`);
}
Am I doing something wrong and/or overcomplicating anything here, or does the template just need to be fixed? Thanks!
Describe the bug
The auto-complete example included in the template application is not functional.
To Reproduce
Generate a new template application with the following:
Install the auto-completion command/script (for your runtime of choice), and try to run the CLI with autocomplete.
Expected behavior
Tab-to-complete works:
Additional context
I'm using
deno
:When I looked at the source code, I noticed an issue with the generated
bash-complete.ts
file:I was able to get things working when I actually iterated over the completion set and wrote the results to stdout (separating each completion by a newline):
Am I doing something wrong and/or overcomplicating anything here, or does the template just need to be fixed? Thanks!