Skip to content

feat: normalize CLI flag conventions (#40) - #42

Merged
scttfrdmn merged 2 commits into
mainfrom
chore/40-flag-normalization
Jun 3, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
chore/40-flag-normalization

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #40. Core of the suite-wide flag normalization. (Companion PRs already merged for truffle #17 and lagotto #17; spored C1 cobra conversion follows.)

JSON output → root -o/--output

Deprecates the remaining per-command --json bools in favor of the root persistent -o/--output selector (matching list/status/sweep status, which were already migrated). Each now honors root -o json and keeps --json as a MarkDeprecated alias for one release:
bot, list-sweeps, plugin, list-amis, pipeline graph, pipeline list.

Confirmation on destructive commands → --yes/-y

Adds --yes/-y + a confirmation prompt to every destructive command via a shared confirmYes(skip, prompt) helper (cmd/utils.go); confirmTerminate now delegates to it.

The new convention gate revealed the gap was suite-wide, not just the 3 commands #40 named — so all are fixed:

  • team delete (was unguarded), team remove, fsx delete (added -y shorthand)
  • instance-terminating: cancel/sweep cancel, pipeline cancel, autoscale terminate
  • record deletes: alerts delete, dns delete, schedule cancel, stage delete, plugin remove

confirmYes treats EOF/piped stdin as "no", so an unattended run without --yes aborts rather than destroying silently (this is what lets nf-spawn etc. drive them safely).

Notable safety fix: spawn cancel terminates all sweep instances and previously had no confirmation at all.

Regression gate

TestFlagConventions (cmd/flag_conventions_test.go) walks the command tree in-process and fails on any undeprecated --json or any destructive verb (cancel/terminate/delete/remove/destroy) missing --yes (--confirm accepted for notify ... destroy). confirmYes covered by TestConfirmYes.

Docs

docs/flag-conventions.md records the conventions: output selector, confirmation, shorthand registry, region vs regions.

Verification

go build ./..., go vet ./..., go test ./cmd/ all green.

Suite-wide flag normalization for spawn (companion PRs done for truffle,
lagotto; spored follows).

JSON output — deprecate the remaining per-command --json bools in favor of
the root -o/--output selector (matches list/status/sweep-status, already
migrated). bot, list-sweeps, plugin, list-amis, pipeline (graph+list) now
honor root -o json and carry MarkDeprecated("json") aliases.

Confirmation — add --yes/-y + a confirmation prompt to every destructive
command via a shared confirmYes() helper (cmd/utils.go); confirmTerminate
now delegates to it. The flag-convention gate surfaced that the gap was
suite-wide, not just the 3 commands #40 named, so all are fixed:
  cancel (sweep), team delete, team remove, fsx delete (added -y shorthand),
  pipeline cancel, sweep cancel, autoscale terminate, alerts delete,
  dns delete, schedule cancel, stage delete, plugin remove.
confirmYes treats EOF/piped stdin as "no", so unattended runs without --yes
abort rather than destroying silently.

Gate — TestFlagConventions walks the command tree in-process and fails on
any undeprecated --json or any destructive verb missing --yes, so the
conventions can't regress. confirmYes covered by TestConfirmYes.

Docs — docs/flag-conventions.md records the conventions (output, confirmation,
shorthand registry, region vs regions).

Closes #40
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.86022% with 55 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/cancel.go 10.00% 9 Missing ⚠️
cmd/team.go 27.27% 8 Missing ⚠️
cmd/pipeline.go 33.33% 6 Missing ⚠️
cmd/plugin.go 33.33% 6 Missing ⚠️
cmd/alerts.go 20.00% 4 Missing ⚠️
cmd/autoscale.go 20.00% 4 Missing ⚠️
cmd/bot.go 20.00% 4 Missing ⚠️
cmd/dns.go 20.00% 4 Missing ⚠️
cmd/schedule.go 20.00% 4 Missing ⚠️
cmd/stage.go 20.00% 4 Missing ⚠️
... and 2 more

📢 Thoughts on this report? Let us know!

team delete gained a confirmation prompt in this PR; the Tier 0 test runs
with a closed stdin (reads as 'no'), so it must pass -y to actually delete.
@scttfrdmn
scttfrdmn merged commit 164f1fa into main Jun 3, 2026
3 checks passed
@scttfrdmn
scttfrdmn deleted the chore/40-flag-normalization branch June 3, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit & normalize flag patterns across the tool suite (-o json vs --json, --yes/-y vs --confirm vs none)

1 participant