Skip to content

feat: expose and document infisical completion command - #332

Open
wankhede04 wants to merge 1 commit into
Infisical:mainfrom
wankhede04:feat/expose-shell-completions
Open

feat: expose and document infisical completion command#332
wankhede04 wants to merge 1 commit into
Infisical:mainfrom
wankhede04:feat/expose-shell-completions

Conversation

@wankhede04

Copy link
Copy Markdown

Type of change

  • Improvement

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

  • Remove HiddenDefaultCmd: true in packages/cmd/root.go so completion shows up in infisical --help.
  • Add a "Shell Completions" section to README.md with copy-paste snippets for bash/zsh/fish.
  • Add 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

$ go build -o infisical .
$ go test -vet=off ./packages/cmd/...
ok  	github.com/Infisical/infisical-merge/packages/cmd	0.66s

$ ./infisical completion bash | head -3
# bash completion V2 for infisical                            -*- shell-script -*-
...
$ ./infisical completion zsh | head -3
$ ./infisical completion fish | head -3
$ ./infisical completion powershell | head -3

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 in run.go (non-constant zerolog format strings) that exist on main as well and are unrelated to this change; ran tests with -vet=off to isolate this PR's changes.

I confirm I have read the Contributing Guide and Code of Conduct.

@infisical-cla-app

infisical-cla-app Bot commented Jul 23, 2026

Copy link
Copy Markdown

CLA satisfied. All contributors have signed the current CLA. The cla/signed check is passing.

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the built-in shell completion command discoverable and documents how to use it. The main changes are:

  • Shows completion in root command help.
  • Adds completion examples for bash, zsh, and fish.
  • Tests command visibility and script generation for four shells.

Confidence Score: 5/5

This looks safe to merge after correcting the zsh setup example.

  • The completion visibility change follows Cobra's default behavior.
  • The tests cover visibility and generation for all supported shells.
  • The zsh documentation can fail to activate completion in the current session.

README.md

Important Files Changed

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

Comment thread README.md
source <(infisical completion bash)

# zsh
infisical completion zsh > "${fpath[1]}/_infisical"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Zsh Session Is Not Activated

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
@wankhede04
wankhede04 force-pushed the feat/expose-shell-completions branch from 18ed89d to 59db748 Compare July 23, 2026 13:29
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.

Shell completion command exists but is hidden and undocumented

1 participant