fix: resolve and validate the output format once, in the root command - #680
Draft
NickJosevski wants to merge 1 commit into
Draft
fix: resolve and validate the output format once, in the root command#680NickJosevski wants to merge 1 commit into
NickJosevski wants to merge 1 commit into
Conversation
--output-format is registered with a default of "table", so the `outputFormat == ""` checks that gate the config file fallback and the --no-prompt fallback never fire. Separately, the 14 commands that hand-roll their own format switch have no default case, so an unsupported -f prints nothing and exits 0. Resolve the format once in the root pre-run and write it back to the flag, so commands can read it and trust it: explicit flag, then config file, then basic when prompting is disabled, then table. Unsupported values now return a usage error. Note this makes --no-prompt yield basic rather than table. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NickJosevski
force-pushed
the
fix/output-format-resolution
branch
from
August 18, 2026 03:11
440e628 to
232f2d1
Compare
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.
Draft: the
--no-promptbehaviour change below needs a call before this is ready. Follow-up to the #328 review.Root cause
--output-formatis registered with a default of"table"(root.go:95), so every downstreamoutputFormat == ""check — the way we ask "did the caller specify a format?" — is unreachable. That's three defects:switch strings.ToLower(outputFormat)with nodefaultcaseOutputFormatconfig setting never appliesprint_resource.go:20,print_array.go:20,config/list/list.go:57--no-promptnever switches to basicroot.go:133-135All three reproduced on
mainwithconfig list(no server needed).Fix
Resolve the format once in the root pre-run and write it back to the flag, so all commands —
output.Mappersusers and holdouts alike — read a validated value. Precedence: explicit flag → config setting →basicwhen prompting is disabled →table.PersistentPreRunbecomesPersistentPreRunEso an unsupported value returns ausage.NewUsageError, matchingPrintResource.resolveOutputFormatis pure and unit tested.Behaviour changes
Reviving dead code can't be a no-op, so:
--no-promptnow yieldsbasic, nottable. That's the intent ofroot.go:133-135, but it's bound to$CIand changes stdout for pipelines that parse it. This is the call I'd like made. The alternative is deleting the dead branch and acceptingtableas the always-default — one line either way. I've also left off aBREAKING CHANGE:footer, since that triggers a major bump; worth deciding together.OutputFormatset now applies. Only affects people who set something that has silently done nothing.-fnow exits 1 with usage instead of exiting 0 silently.Passing
-f tableexplicitly is unaffected.Out of scope
Migrating the 14 holdouts to
PrintResource/PrintArray— that changes output shape, so it wants its own PR per command. Central validation closes the exit-0 gap without touching them:config/list,release/{list,deploy,create},runbook/{list,run},runbook/snapshot/{list,create},ephemeralenvironment/util,task/wait,package/{zip,nuget}/create,package/upload,root.Testing
go test ./pkg/...passes; 11 precedence + 3 rejection cases inroot_test.go. Manually verified all three defects fixed, valid formats unchanged, and the legacy--outputFormatalias still resolving (it sets the value without marking the flagChanged, whichresolveOutputFormathandles).🤖 Generated with Claude Code