Skip to content

Rework complete command for Commander#125

Open
shadowspawn wants to merge 10 commits into
bombshell-dev:mainfrom
shadowspawn:rework-complete-command
Open

Rework complete command for Commander#125
shadowspawn wants to merge 10 commits into
bombshell-dev:mainfrom
shadowspawn:rework-complete-command

Conversation

@shadowspawn

@shadowspawn shadowspawn commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Rework Commander framework implementation to remove need to monkeypatch .parse()+.parseAsync(), and optionally allow separate complete and completion commands. Commander allows customising name of other built-in commands and options like version and help.

With separate commands, can show correct user facing syntax completion <shell> and not need to detect difference between completion (complete <shell>) and complete (complete -- [args]).

If maintainers ok with this approach, I'll mention the customisation option in the README.

…ommands, and remove need to monkeypatch parse+parseAsync
@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e4f7295

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bomb.sh/tab Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shadowspawn

shadowspawn commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

This is the UX experience for this PR with the tab-style combo complete command.

% my-cmd --help
Usage: my-cmd [options] [command]

Options:
  -V, --version     output the version number
  -h, --help        display help for command

Commands:
  serve [options]   Start the server
  complete [shell]  Generate shell completion scripts
  help [command]    display help for command
% my-cmd complete --help
Usage: my-cmd complete [options] [shell]

Generate shell completion scripts

Arguments:
  shell       shell type (choices: "zsh", "bash", "fish", "powershell")

Options:
  -h, --help  display help for command
% my-cmd complete       
error: missing required argument 'shell'
% my-cmd complete x
error: command-argument value 'x' is invalid for argument 'shell'. Allowed choices are zsh, bash, fish, powershell.

This is the UX experience with a custom name (completion) for the visible script command.

% my-cmd --help         
Usage: my-cmd [options] [command]

Options:
  -V, --version       output the version number
  -h, --help          display help for command

Commands:
  serve [options]     Start the server
  completion <shell>  Generate shell completion scripts
  help [command]      display help for command
% my-cmd complete --help
Usage: my-cmd complete -- [args...]

Generate completion suggestions

Options:
  -h, --help  display help for command
% my-cmd completion --help 
Usage: my-cmd completion [options] <shell>

Generate shell completion scripts

Arguments:
  shell       Shell type for completion script (choices: "zsh", "bash", "fish", "powershell")

Options:
  -h, --help  display help for command
% my-cmd completion
error: missing required argument 'shell'
% my-cmd completion x
error: command-argument value 'x' is invalid for argument 'shell'. Allowed choices are zsh, bash, fish, powershell.

@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tab@125

commit: e4f7295

@AmirSa12 AmirSa12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean and very, very interesting refactor. thanks

would you want to document that in this PR or a separate one?

@AmirSa12

AmirSa12 commented Jun 6, 2026

Copy link
Copy Markdown
Member

I'll make an issue to add the same optional config for the other two adapters

Comment thread src/commander.ts Outdated
@shadowspawn

Copy link
Copy Markdown
Contributor Author

would you want to document that in this PR or a separate one?

I'll have a go in this PR.

@AmirSa12

AmirSa12 commented Jun 7, 2026

Copy link
Copy Markdown
Member

would you want to document that in this PR or a separate one?

I'll have a go in this PR.

Thank you!
curious if you have any of discord/x/bluesky?

@shadowspawn

Copy link
Copy Markdown
Contributor Author

curious if you have any of discord/x/bluesky?

Only regularly use Bluesky. Reader not poster. Following @bomb.sh. 😄

@shadowspawn

Copy link
Copy Markdown
Contributor Author

I added a special error in case user has separate complete and completion commands, but follows an example to call (say) complete bash. Might be overthinking it, but I am aware separate commands is non-standard for current tab and want to help user resolve the usage error.

% my-cmd complete bash   
error: completion requests are called like `complete -- [args]`.
(Did you mean `completion bash` to generate shell script?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants