Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-pants-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bomb.sh/tab": patch
---

fix: should complete options after boolean option
5 changes: 4 additions & 1 deletion src/t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ export class RootCommand extends Command {
const [flag] = toComplete.split('=');
optionName = flag;
} else if (lastPrevArg?.startsWith('-')) {
optionName = lastPrevArg;
const option = this.findOption(command, lastPrevArg);
if (option && !option.isBoolean) {
optionName = lastPrevArg;
}
}

if (optionName) {
Expand Down
7 changes: 7 additions & 0 deletions tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ describe.each(cliTools)('cli completion tests for %s', (cliTool) => {
// Should complete subcommands that start with 's' even after a boolean option
expect(output).toContain('start');
});

it('should not interfere with option completion after boolean options', async () => {
const command = `${commandPrefix} dev --verbose --h`;
const output = await runCommand(command);
// Should complete subcommands that start with 's' even after a boolean option
expect(output).toContain('--host');
});
});

describe.runIf(!shouldSkipTest)('option API overload tests', () => {
Expand Down