feat(cli): add catalog-aware value completions - #415
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds catalog-aware, deterministic value completion to the CLI by introducing explicit “value completion policies” in the command/flag registry and wiring those into Cobra’s completion protocol. It sources candidates from typed catalogs (export datasets, Google Health Data Types/endpoints, rollup kinds, scope keywords, and source families), preserves CSV prefixes while deduplicating, and keeps filesystem completion enabled only for path values.
Changes:
- Add completion policy metadata to
commandDef/flagSpec, validate registry coverage, and register per-flag/per-positional completion handlers. - Introduce canonical catalog projection helpers for raw targets/endpoints, syncable/listable data types, and supported source families (with drift-guard tests).
- Update CLI help/docs to describe catalog-backed completions and path-only filesystem fallback.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/googlehealth/scopes.go | Adds RawEndpointNames() catalog projection for raw endpoint completion. |
| internal/googlehealth/fetch.go | Introduces typed raw target kinds and exposes RawTargetNames() for completion. |
| internal/googlehealth/fetch_extra_test.go | Adds drift tests for raw endpoint/target completion projections. |
| internal/googlehealth/catalog.go | Adds completion views (SyncableDataTypes, ListableDataTypes, SupportedSourceFamilies) and source-family catalog mapping. |
| internal/googlehealth/catalog_test.go | Adds drift tests for completion view projections and copy safety. |
| cmd/gohealthcli/sync.go | Uses catalog-backed usage strings for rollup and source-family flags. |
| cmd/gohealthcli/connect_add_scopes.go | Exposes sorted scope keyword names for completion and keeps usage derived from canonical keyword set. |
| cmd/gohealthcli/completion.go | Implements policy-driven Cobra completion for flags/positionals, CSV prefix preservation, dedup, and sorting. |
| cmd/gohealthcli/completion_test.go | Adds protocol-level tests for catalog candidates, directives, stability, sorting, and path-only filesystem fallback. |
| cmd/gohealthcli/common_flags.go | Marks --config and --db as file-completable (filesystem fallback). |
| cmd/gohealthcli/commands.go | Adds completion policy fields and populates them across command registry surfaces. |
| docs/install.md | Documents catalog-backed completions and path-only filesystem fallback behavior. |
| docs/commands/completion.md | Updates completion command docs to reflect new value completion behavior and constraints. |
💡 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
make fmt-checkgo test ./...go test -race ./...make buildmake docs-checkmake docs-siteplus full Pages artifact smokewindow=, path-only fallback, and deterministic generationgo vet ./...,go mod verify, govulncheck (no vulnerabilities), TruffleHog/autoreview cleanNotes