Repository navigation
feat(cli): replace per-command --json with a global --output/-o - #121
Merged
Merged
Conversation
P1 foundation (PR-1.3) of the CLI UX overhaul. Add a persistent --output/-o (text|json, env YACD_OUTPUT) as the single machine-output toggle, validated once in PersistentPreRunE, and remove the per-command --json flags and all YACD_JSON handling from list/info/wallet outright (pre-1.0 clean cut, no alias). The JSON branches now gate on commandContext.outputJSON() (a viper-backed read of the validated --output value); the frozen JSON byte shapes are unchanged. PR-1.4 swaps these reads to cc.io.JSON() once the resolved ui.IO is threaded — routing through cc.io now is impossible because cc.io does not exist until then. Also introduce formatText/formatJSON constants to keep the new enum handling under the goconst threshold. Tests/Chainsaw: the --json invocations move to -o json (byte-identical output); new coverage for --json being unknown, YACD_OUTPUT validation/precedence, the output default, and the outputJSON helper. BREAKING (pre-1.0, intentional): --json and YACD_JSON are removed; use --output json / -o json (YACD_OUTPUT=json). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 8, 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.
Summary
P1 / PR-1.3 of the CLI UX overhaul. Replaces the scattered per-command
--jsonflags with one global--output/-o.--jsonandYACD_JSONare removed fromlist/info/walletoutright (no alias, no deprecation).--output/-o(text|json, envYACD_OUTPUT) is the only machine-output toggle. Existing JSON byte shapes are unchanged.What's here
--output -o(defaulttext), bound tooutput/YACD_OUTPUT, validated once inPersistentPreRunE(addedOutputFormattoRuntimeConfig).--jsonflag registrations + allviper.GetBool("json")reads inlist.go/info.go/wallet.go; the JSON branches now gate on a newcommandContext.outputJSON()helper.formatText/formatJSONconstants (the new enum handling crossed thegoconstthreshold).Sequencing note (deviation from the 063 plan, intentional)
The 063 plan said PR-1.3 should route the JSON branch through
cc.io.JSON(). That's impossible here —cc.ioisn't built until PR-1.4 (the merged-context PR). So PR-1.3 reads the validated--outputvalue viaoutputJSON()(viper-backed); PR-1.4 swaps these reads tocc.io.JSON()once the resolvedui.IOis threaded. The validatedOutputFormatfield lands now so PR-1.4 only re-points the read sites.Testing
gofmt/go vet/go buildclean;golangci-lint0 issues;moon run root:check+moon run root:test(full envtest gate) green;git diff --checkclean.--jsoninvocations inlist_test/info_testand the Chainsaw e2e (info … -o json) moved to-o json(byte-identical output — the frozen shapes are untouched).output_test.go:--jsonis now an unknown flag;YACD_OUTPUTis read + validated (a bogus value fails before the command runs); output defaults totext;outputJSON()is case-insensitive.Part of the P1 foundation series (1.1 #119, 1.2 #120 merged → 1.3 → … → 1.6).
🤖 Generated with Claude Code