cli: share hidden-command list via command.Spec.IsHidden so docs honor it#213
Merged
Conversation
…truth The hidden-command decision (pre-launch endpoints omitted from --help) lived in cmd/heygen (package main), so it was unreachable to anything outside the CLI binary. The EF docs generator, which imports gen and iterates raw specs, could not honor it and would publish pre-launch commands (e.g. `asset search`) to the public docs. Move the list + predicate to internal/command as Spec.IsHidden() so both the runtime builder (hides from --help) and the docs generator (omits from public docs) share one source of truth. Behavior in the CLI is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jrusso1020
reviewed
Jul 11, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at 19f69cf1. Small, well-scoped extraction — moves the CLI's hidden-command predicate from the private cmd/heygen binary into internal/command so both the runtime and the docs generator share one source of truth.
Verified
- Move, not duplicate: the old
hiddenCommandsmap +isHiddenCommandfunction are FULLY REMOVED fromcmd/heygen/builder.go(grep-clean — no dead code). The new home ininternal/command/hidden.gocarries the same fixture (GET /v3/assets/search) and the samestrings.ToUpper(Method) + " " + Endpointcase-insensitive keying. Runtime behavior byte-identical. - Value-receiver method
(s Spec) IsHidden() bool— as the body claims, this lands in the method set of bothSpecand*Specper Go method-set rules, so a package that imports onlygen(e.g. EF'scli_docs_dump/main.go) can calls.IsHidden()on a*command.Specvalue without needing to importinternal/command. That's the key architectural decision this PR makes correctly. - Cobra builder wiring:
Hidden: spec.IsHidden()atbuilder.go:40— wasisHiddenCommand(spec), semantically equivalent. - Empty-group hiding preserved:
help_flatten.gochanges are comment-only (hiddenCommandsvariable →command.Spec.IsHidden). ThehideEmptyGroupswalk still runs bottom-up and hides any group whose only leaf is hidden. - Test coverage preserved + updated:
hidden_commands_test.gorenames 3 assertions fromisHiddenCommand(x)tox.IsHidden(). Still exercises (a) uppercase METHOD (hidden), (b) lowercase METHOD (verify case-insensitive), (c) visible endpoint (not hidden). Discipline preserved.
CI
govulncheck red — pre-existing on main (same failure signature at 2026-07-11T00:07:40Z on main/HEAD), not introduced by this PR. All the checks touched by this diff (build, lint, unit tests) are green.
Non-blocking notes
- Hidden set is transitional: Somansh's inline docstring names this correctly — the long-term move is
x-cli-hiddenin the OpenAPI spec so the spec stays the source of truth. Fine to keep the hand-maintained list for now; low-cost future change. - Merge ordering: the companion EF#41881 correctly notes this must merge first (the dumper compiles against heygen-cli's default branch during the sync job, so
s.IsHidden()must exist onmainfirst, else the docs-sync workflow would fail at compile time).
Verdict
Clean refactor with the right architectural choice (value-receiver → cross-package callable). Ready to merge, holding stamp per protocol until you explicitly ask.
— Rames Jusso
jrusso1020
approved these changes
Jul 11, 2026
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.
Scope
Surfaces: CLI + docs pipeline | Module: Codegen / command surface
Summary
Pre-launch commands the CLI deliberately hides from
--help(currentlyasset search) were about to leak into the public/commandsdocs, because the docs generator had no way to see the CLI's hidden set. This moves that set to a shared source of truth both the CLI runtime and the docs generator honor.Root cause
The hidden-command list and its predicate lived in
cmd/heygen(packagemain). Anything outside the CLI binary, including the EF docs generator that imports thegenpackage and iterates raw specs, could not reach it, so it treated every generated command as public.Fix
Moved the list + predicate to
internal/commandas a value-receiver methodSpec.IsHidden(). The builder now sets CobraHiddenviaspec.IsHidden(). A value receiver is deliberate: it lands in the method set of bothSpecand*Spec, so a package that imports onlygencan calls.IsHidden()on the*command.Specvaluesgenexposes without importinginternal/command. CLI behavior is unchanged — the same map, the same case-insensitiveMETHOD /pathkeying.The companion EF change (docs generator skipping hidden specs) depends on this method existing on the default branch, so this merges first.
Testing
go build,make lint(0 issues),go test ./cmd/heygen ./internal/command(all pass). Runtime-verified:asset searchis absent fromasset --help, still runnable viaasset search --help, and empty-group hiding still works. Also ran the patched EF dumper against this branch to confirm/v3/assets/searchis excluded while the real asset commands remain.