-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Background
scripts/check-cli-surface.sh merges $ROOT_FLAGS (all root command flags) into every subcommand's flag list at line 45:
ROOT_FLAGS=$("$BINARY" --help --agent 2>/dev/null | jq -c '[.flags // [] | .[] | {name, type}]')
# ...
((.flags // []) + (.inherited_flags // []) + $root | group_by(.name) | map(.[0]) | sort_by(.name))This incorrectly propagates --version to all subcommands. Cobra adds --version as a local flag on the root (via InitDefaultVersionFlag), not a persistent one — it does not inherit to subcommands.
Impact
The Go surface walker (github.com/basecamp/cli/surface v0.2.1) correctly omits --version from subcommands. This creates a 612-entry divergence between the shell script and the Go walker. Documented in PR #366.
Fix
Change $ROOT_FLAGS to only include root persistent flags, not all root flags. The --help --agent JSON already distinguishes .flags from .inherited_flags — filter $ROOT_FLAGS to only the persistent subset, or use inherited_flags from the root's children instead of force-merging root flags.
Related
- PR Regenerate .surface from Go walker with ARG and alias support #366 — documents the divergence
scripts/check-smoke-coverage.sh:54— has a hardcodedalias_mapfor campfire→chat that is now redundant since.surfaceincludes alias paths natively