Skip to content

Commit 986935b

Browse files
fix: address review comments (doc pipe escaping, chained integration test)
Agent-Logs-Url: https://github.com/crypto-vincent/cli-kiss/sessions/43b1d432-423c-4a04-817c-5c3dafc4386e Co-authored-by: crypto-vincent <106254129+crypto-vincent@users.noreply.github.com>
1 parent e7bb8a3 commit 986935b

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

docs/guide/06_run_as_cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ This adds two hidden flags:
158158
159159
| Flag | Description |
160160
| ----------------------------- | ------------------------------------------------------------------------ |
161-
| `--completion [bash\|zsh\|fish]` | Prints a shell completion script; source it in your shell init file |
161+
| `--completion [bash|zsh|fish]` | Prints a shell completion script; source it in your shell init file |
162162
| `--get-completions -- <args>` | Returns one completion per line for the given typed args (used by scripts) |
163163
164164
### Install the completion script

tests/unit.completion.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ it("runAndExit completion", async function () {
236236
// --get-completions with partial/unknown input does not produce a parse error
237237
await testGetCompletionsRun(["--invalid-partial"], [], []);
238238

239+
// --get-completions for a commandChained root: options from both stages are present
240+
const chainedRoot = commandChained(
241+
{ description: "Chained root" },
242+
operation(
243+
{ options: { dbg: optionFlag({ long: "dbg" }) }, positionals: [] },
244+
async (ctx) => ctx,
245+
),
246+
buildCmd,
247+
);
248+
await testGetCompletionsRunWith(
249+
chainedRoot,
250+
[],
251+
["--dbg", "--verbose", "--output"],
252+
[],
253+
);
254+
239255
// completionSetup not enabled → --completion is an unknown option → exit 1
240256
await testCompletionDisabled();
241257
});
@@ -269,6 +285,20 @@ async function testGetCompletionsRun(
269285
completedArgs: Array<string>,
270286
expectedToContain: Array<string>,
271287
expectedNotToContain: Array<string>,
288+
) {
289+
await testGetCompletionsRunWith(
290+
rootCommand,
291+
completedArgs,
292+
expectedToContain,
293+
expectedNotToContain,
294+
);
295+
}
296+
297+
async function testGetCompletionsRunWith(
298+
cmd: Parameters<typeof runAndExit>[3],
299+
completedArgs: Array<string>,
300+
expectedToContain: Array<string>,
301+
expectedNotToContain: Array<string>,
272302
) {
273303
const onLogStdOut = makeMocked<string, void>(
274304
Array(100).fill(null as unknown as void),
@@ -281,7 +311,7 @@ async function testGetCompletionsRun(
281311
"my-cli",
282312
["--get-completions", "--", ...completedArgs],
283313
null,
284-
rootCommand,
314+
cmd,
285315
{
286316
completionSetup: "flag",
287317
buildVersion: "1.0.0",

0 commit comments

Comments
 (0)