Skip to content

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

Closed

Description

@scttfrdmn

Problem

Flag conventions have drifted across spawn's command surface — surfaced while building the Tier 0 integration suite, which had to special-case several commands. Two clear inconsistency classes:

1. JSON output: root -o/--output json vs per-command --json

The root persistent flag is the canonical selector:

cmd/root.go:58  rootCmd.PersistentFlags().StringVarP(&spawnOutputFormat, "output", "o", "table", "Output format (table, json)")

…but 8 commands define their own local --json bool that duplicates (and can shadow/diverge from) it:

bot.go  list.go  list_amis.go  list-sweeps.go  pipeline.go  plugin.go  sweepgroup.go  status.go

Result: spawn list -o json works, but spawn list-sweeps -o json does not — list-sweeps only honors --json. A wrapper/CI script can't assume one convention. (Tier 0 had to remember which commands take which.)

2. Confirmation flags: --yes/-y vs --yes (no shorthand) vs --confirm vs none

launch.go:293     --yes / -y     (BoolVarP)
terminate.go:45   --yes / -y     (BoolVarP)
slurm.go:113      --yes / -y     (BoolVarP)
fsx.go:60         --yes          (BoolVar — NO -y shorthand)
bot.go:1047       --confirm      (different name; dry-run-by-default semantics)
team.go (delete)  (no confirmation flag at all — deletes immediately)

So spawn fsx delete --yes works but -y doesn't; spawn team delete <id> has no guard; bot ... destroy uses --confirm. Destructive commands should be consistent and uniformly guarded.

Proposed work

  1. Audit every command's flags (spawn, and the same pass for truffle/lagotto since they share conventions and the i18n/output layers).
  2. JSON output: standardize on the root -o/--output json. Make every command that emits structured data honor it; deprecate the local --json bools (keep as hidden aliases for one release with a deprecation notice, then remove).
  3. Confirmation: standardize on --yes/-y everywhere a command mutates/destroys; ensure all destructive commands (notably team delete) actually prompt without it. Decide whether bot destroy's --confirm/dry-run-by-default stays special or converts.
  4. Guard against regressions: add a Tier 0 test asserting the JSON-output and confirmation conventions hold across the command tree (Tier 0 already exercises much of this surface, e.g. TestTier0_JSONOutputMatrix, TestTier0_TerminateRequiresConfirmation).
  5. Document the conventions in CONTRIBUTING / a flags style note so new commands follow them.

Notes

  • This is partly user-facing (flag deprecation), so the --json aliases should warn for a release before removal.
  • Consider a small shared helper / lint to enforce "no per-command --json; use root -o" going forward.
  • Found via the Tier 0 CLI-against-substrate suite; that suite is the natural place to lock the normalized conventions in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions