Skip to content

fix(cmd): reject an unrecognised --output value - #132

Merged
Ilyes512 merged 1 commit into
mainfrom
fix/GH-115-validate-output-format
Sep 4, 2026
Merged

fix(cmd): reject an unrecognised --output value#132
Ilyes512 merged 1 commit into
mainfrom
fix/GH-115-validate-output-format

Conversation

@Ilyes512

@Ilyes512 Ilyes512 commented Sep 2, 2026

Copy link
Copy Markdown
Member

The writer selection had a default arm, so any value that was not exactly
"json" was silently accepted as pretty: specs -o josn version exited 0 with
plausible output. A typo in a pipeline then failed several lines later at the
jq, with a parse error rather than a message naming the flag.

output.Format now names the accepted values, so the flag default, the writer
selection and the help text read from one place instead of repeating a bare
string literal. PersistentPreRunE rejects anything else.

The writer is wired before the format is validated. That ordering reads
backwards on purpose: main reports the returned error through app.Output, so a
rejection raised while it is still nil would have nowhere to go.

Closes #115


Stack created with GitHub Stacks CLIGive Feedback 💬

The writer selection had a default arm, so any value that was not exactly
"json" was silently accepted as pretty: `specs -o josn version` exited 0 with
plausible output. A typo in a pipeline then failed several lines later at the
jq, with a parse error rather than a message naming the flag.

output.Format now names the accepted values, so the flag default, the writer
selection and the help text read from one place instead of repeating a bare
string literal. PersistentPreRunE rejects anything else.

The writer is wired before the format is validated. That ordering reads
backwards on purpose: main reports the returned error through app.Output, so a
rejection raised while it is still nil would have nowhere to go.

Closes #115
@Ilyes512
Ilyes512 marked this pull request as ready for review September 2, 2026 22:20
@Ilyes512
Ilyes512 merged commit 2ae6e40 into main Sep 4, 2026
5 checks passed
@Ilyes512
Ilyes512 deleted the fix/GH-115-validate-output-format branch September 4, 2026 10:10
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.

cmd: --output accepts any value and silently falls back to pretty

1 participant