feat: add shell completion scripts - #622
Merged
Merged
Conversation
Generate completion scripts from the CLI definitions for Bash, Zsh, Fish, Elvish, and PowerShell. Shell users had no way to complete CLI options and subcommands. Exit before loading configuration or connecting to a cluster. Closes #621
Greptile SummaryAdds a configuration-independent
Confidence Score: 5/5The PR appears safe to merge; no actionable correctness, security, or repository-rule violations were identified. Completion generation is reached immediately after parsing and exits before configuration or cluster initialization, while the reserved resource-name behavior and supported shell inputs are documented and tested. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Start sofka"] --> B["Parse CLI arguments"]
B --> C{"completion subcommand?"}
C -->|Yes| D["Build Clap command definition"]
D --> E["Generate script for selected shell"]
E --> F["Write script to stdout and exit"]
C -->|No| G["Apply kubeconfig override"]
G --> H["Create Tokio runtime"]
H --> I["Load configuration and start normal CLI flow"]
Reviews (1): Last reviewed commit: "feat: add shell completion scripts" | Re-trigger Greptile |
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.
Shell users cannot complete sofka CLI options or subcommands. Add
sofka completion <shell>for Bash, Zsh, Fish, Elvish, and PowerShell, with scripts generated from the CLI definitions and setup instructions for each shell.Generation exits before configuration loading, runtime startup, or cluster access. Live resource, namespace, and context values are outside this scope. Use
--resource completionto open a resource with the same name.Validation:
just check; binary tests for all five script outputs, invalid or missing shell names, and generation with malformed local configuration. Bash, Zsh, and Fish script loading and completion checks also pass. Elvish and PowerShell are not installed locally, so their scripts have output checks only.Agreed discussion: #620
Closes #621
Two concurrent pre-commit runs failed in the existing
port_forward_picker_keeps_selection_when_local_port_is_in_usetest. It passed in the first full run and in an isolated retry. No port-forward code was changed.All pre-commit hooks passed with
RUST_TEST_THREADS=1, including the complete test suite.