Skip to content

feat(cli): add phantom completion <shell> for shell completions#47

Open
SAY-5 wants to merge 1 commit intoashlrai:mainfrom
SAY-5:feat/shell-completion
Open

feat(cli): add phantom completion <shell> for shell completions#47
SAY-5 wants to merge 1 commit intoashlrai:mainfrom
SAY-5:feat/shell-completion

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 29, 2026

Summary

Closes #36.

Phantom has 27 commands and many take flags. Tab-completion makes
day-to-day use much faster, especially for new users learning the
command surface. This adds a `completion ` subcommand that
prints a `clap_complete`-generated script to stdout for bash,
zsh, fish, powershell, and elvish; users source it from their shell
rc per the README guidance:

```bash

bash

phantom completion bash > ~/.local/share/bash-completion/completions/phantom

zsh

phantom completion zsh > "${fpath[1]}/_phantom"

fish

phantom completion fish > ~/.config/fish/completions/phantom.fish

powershell

phantom completion powershell | Out-String | Invoke-Expression
```

Implementation

Followed the issue's outline:

  • `clap_complete = "4"` added to
    `crates/phantom-cli/Cargo.toml`.
  • New `Completion { shell: clap_complete::Shell }` variant on the
    top-level `Commands` enum, dispatched in
    `match cli.command`.
  • Helper module `commands/completion.rs` calls
    `generate(shell, &mut Cli::command(), "phantom", &mut io::stdout())`.

`Cli` and the `commands` module are crate-internal — no `pub`
is required because the helper lives inside the same binary crate.

Test plan

  • Unit test `commands::completion::tests::completion_runs_for_every_shell_variant`
    runs the helper for every shell clap_complete knows about
    (Bash, Zsh, Fish, PowerShell, Elvish) and asserts it returns
    `Ok`. We don't parse the generated text — that's
    `clap_complete`'s contract — but the smoke locks in that
    the command stays wired up as `Cli` evolves.
  • `phantom completion bash` prints a `_phantom() { ... }`
    function.
  • `phantom completion zsh` prints `#compdef phantom`.
  • `cargo test -p phantom-secrets --bin phantom commands::completion`:
    1 passed, 0 failed.
  • `cargo clippy -p phantom-secrets --all-targets -- -D warnings`:
    clean.
  • `cargo fmt --all -- --check`: clean.

Notes

The README's "Command Reference" table update from the issue's
"definition of done" is not in this PR — happy to extend the
PR with the README row if you'd prefer it bundled, but I left it
out to keep the diff focused on the feature; sourcing the helper
already works without any docs change.

…hlrai#36)

Phantom has 27 commands and many take flags. Tab-completion makes
day-to-day use much faster, especially for new users learning the
command surface. Add a `completion <shell>` subcommand that prints a
clap_complete-generated script to stdout for bash, zsh, fish,
powershell, and elvish; users source it from their shell rc.

Implementation follows the issue's outline:

- Add `clap_complete = "4"` to `crates/phantom-cli/Cargo.toml`.
- New `Completion { shell: clap_complete::Shell }` variant on the
  top-level `Commands` enum, wired through `match cli.command`.
- Helper module `commands/completion.rs` calls
  `generate(shell, &mut Cli::command(), "phantom", &mut io::stdout())`.

`Cli` and the `commands` module are crate-internal — no `pub` is
needed because the helper lives inside the same binary crate.

A unit test in `commands/completion::tests` runs the helper for every
shell variant clap_complete knows about (Bash, Zsh, Fish, PowerShell,
Elvish) and asserts it returns `Ok`. We don't parse the generated
text — that's clap_complete's contract — but the smoke locks in
that the command stays wired up as `Cli` evolves.

Local verification:

- `phantom completion bash` prints a `_phantom() { ... }` function.
- `phantom completion zsh` prints `#compdef phantom`.
- `cargo test -p phantom-secrets --bin phantom commands::completion`:
  1 passed, 0 failed.
- `cargo clippy -p phantom-secrets --all-targets -- -D warnings`: clean.
- `cargo fmt --all -- --check`: clean.

Closes ashlrai#36
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

@SAY-5 is attempting to deploy a commit to the Evero Team on Vercel.

A member of the Team first needs to authorize it.

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.

Add shell completion: phantom completion <bash|zsh|fish|powershell>

1 participant