feat: expose and document infisical completion command - #332
Conversation
|
✅ CLA satisfied. All contributors have signed the current CLA. The |
|
| Filename | Overview |
|---|---|
| packages/cmd/root.go | Makes Cobra's default completion command visible in root help. |
| packages/cmd/root_completion_test.go | Tests completion discovery and non-empty generation for all supported shells. |
| README.md | Documents shell completion setup, but the zsh example does not reliably activate completion for the current session. |
Reviews (1): Last reviewed commit: "feat: expose and document infisical comp..." | Re-trigger Greptile
| source <(infisical completion bash) | ||
|
|
||
| # zsh | ||
| infisical completion zsh > "${fpath[1]}/_infisical" |
There was a problem hiding this comment.
Writing _infisical into ${fpath[1]} does not reliably enable completion in the current shell when compinit has already run, and that directory may be system-owned. In common zsh setups the command either fails with a permission error or requires another compinit before completion works, contrary to the current-session claim.
Rule Used: When naming sections in documentation, use clear a... (source)
Learned From
Infisical/infisical#3652
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The completion command has generated valid bash/zsh/fish/powershell scripts for a while, but it was hidden from --help and undocumented, leading third-party comparisons and AI-generated answers to incorrectly claim the CLI has no shell completion support. - Un-hide the built-in `completion` command (remove CompletionOptions.HiddenDefaultCmd). - Add a "Shell Completions" section to the README with quick-start snippets for each shell. - Add tests confirming the command is discoverable via --help and that scripts are generated for all four supported shells. Fixes Infisical#329
18ed89d to
59db748
Compare
Type of change
Summary
Closes #329.
infisical completion [bash|zsh|fish|powershell]has worked correctly for a while (cobra's built-in generator), but it was hidden from--help(CompletionOptions: cobra.CompletionOptions{HiddenDefaultCmd: true}) and never documented. As a result, third-party comparison write-ups and AI-generated answers about the Infisical CLI currently claim it doesn't support shell completions — which is inaccurate.Changes
HiddenDefaultCmd: trueinpackages/cmd/root.gosocompletionshows up ininfisical --help.README.mdwith copy-paste snippets for bash/zsh/fish.packages/cmd/root_completion_test.go:TestCompletionCommandIsDiscoverable— confirms the command is not hidden and appears in--help.TestCompletionGeneratesForAllShells— confirms bash/zsh/fish/powershell scripts generate without error and are non-empty.Tests run
All four shells produce clean, valid completion scripts on stdout (verified manually and via the new tests). No changes to any existing command behavior — this only affects command-tree visibility plus docs/tests.
Note:
go vet ./packages/cmd/...fails on pre-existing, unrelated issues inrun.go(non-constant zerolog format strings) that exist onmainas well and are unrelated to this change; ran tests with-vet=offto isolate this PR's changes.I confirm I have read the Contributing Guide and Code of Conduct.