Fix --version over-propagation in check-cli-surface.sh

Merged
SA
5mo ago
+4-1

Summary

scripts/check-cli-surface.sh merged ALL root .flags (22 entries) into every subcommand, including local-only flags like --version that Cobra does not propagate to children. This created a ~612-entry divergence vs the Go surface walker (github.com/basecamp/cli/surface).

Fix

Derive $ROOT_FLAGS from a child command's inherited_flags instead of the root's .flags. This captures only the 5 persistent flags Cobra actually propagates (account, json, md, project, quiet), excluding 17 local-only flags (version, agent, verbose, cache-dir, etc.).

Before → After

MetricBeforeAfter
Root flags merged into subcommands225
--version in subcommand surface✗✓ (correctly omitted)
Surface lines~10,900~7,750

Testing

# Verify root still has all its flags
./bin/basecamp --help --agent | jq ".flags | length"  # 22

# Verify children only inherit persistent flags
./bin/basecamp todos --help --agent | jq ".inherited_flags | length"  # 5

# Regenerate surface and confirm no --version in subcommands
bash scripts/check-cli-surface.sh ./bin/basecamp /tmp/surface.txt
grep "FLAG basecamp account --version" /tmp/surface.txt  # no match
grep "FLAG basecamp --version" /tmp/surface.txt          # match (root only)

Closes #368


Summary by cubic

Fixes incorrect flag propagation in scripts/check-cli-surface.sh by only inheriting persistent flags for subcommands. This removes --version and other local-only flags from subcommand surfaces and restores parity with the Go walker github.com/basecamp/cli/surface.

  • Bug Fixes
    • Derive ROOT_FLAGS from a subcommand’s inherited_flags instead of the root’s .flags.
    • Subcommands now include only 5 persistent flags; --version is root-only; surface size drops from ~10,900 to ~7,750 lines.