feat(cli): add phantom completion <shell> for shell completions#47
Open
SAY-5 wants to merge 1 commit intoashlrai:mainfrom
Open
feat(cli): add phantom completion <shell> for shell completions#47SAY-5 wants to merge 1 commit intoashlrai:mainfrom
phantom completion <shell> for shell completions#47SAY-5 wants to merge 1 commit intoashlrai:mainfrom
Conversation
…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
|
@SAY-5 is attempting to deploy a commit to the Evero Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
`crates/phantom-cli/Cargo.toml`.
top-level `Commands` enum, dispatched in
`match cli.command`.
`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
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.
function.
1 passed, 0 failed.
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.