feat(cli): generate registry-backed shell completions - #414
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new gohealthcli completion subcommand that generates deterministic, registry-projected shell completion scripts (Bash, Zsh, Fish, PowerShell) while keeping the CLI’s production parsing on the standard library and using Cobra only for completion script/protocol handling.
Changes:
- Introduces a registry-backed
completioncommand (with--no-descriptions) and wires Cobra-based completion protocol handling ahead of stdlib flag parsing. - Adds comprehensive tests for script validity, determinism, completion protocol behavior, and “no side effects” (no config/archive/provider reads/writes).
- Updates user documentation and generated command reference pages to include completion setup instructions for all four shells.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds completion to the top-level command list. |
| go.mod | Adds Cobra as a dependency for completion generation/protocol support. |
| go.sum | Records new dependency checksums (Cobra + transitive deps). |
| docs/install.md | Documents current-session and persistent completion installation for Bash/Zsh/Fish/PowerShell. |
| docs/commands/completion.md | New command reference page for gohealthcli completion. |
| docs/commands.md | Adds completion to the command index. |
| cmd/gohealthcli/schema_test.go | Updates registry coverage test to include completion. |
| cmd/gohealthcli/main.go | Routes Cobra completion protocol requests before stdlib parsing/runtime defaults. |
| cmd/gohealthcli/completion.go | Implements registry-projected Cobra command tree and completion script generation. |
| cmd/gohealthcli/completion_test.go | Adds determinism/protocol/side-effect tests for completion generation. |
| cmd/gohealthcli/commands.go | Registers the completion command and wires its Run adapter in init(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Proof
go test ./...go test -race ./...make fmt-checkgolangci-lint v2.12.2: 0 issuesmake docs-checknode --test scripts/*.test.mjsmake docs-sitegovulncheck ./...: no vulnerabilities foundCloses #400