Skip to content

Silence Cobra's usage dump on command errors - #128

Merged
quad341 merged 3 commits into
mainfrom
deploy/crn-ybgbs-gate
Aug 20, 2026
Merged

quad341 merged 3 commits into
mainfrom
deploy/crn-ybgbs-gate

Conversation

@quad341

@quad341 quad341 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Errors from any subcommand were getting buried under Cobra's default usage/help block, pushing the actual error message off the top of a truncated terminal view.

Sets SilenceUsage: true on the root command so the usage dump no longer prints on error, matching the behavior a couple of individual commands already opted into locally — now applied globally. Includes a regression test covering the original symptom.

cairn-reviewer-scratch added 3 commits August 19, 2026 17:28
TestRootSilencesUsageOnError reproduces crn-rott9's reported symptom: a RunE/PersistentPreRunE error currently surfaces buried under Cobra's default usage/help dump, pushing the real error line off the top of a tail-8'd terminal.
Cobra's ExecuteC checks SilenceUsage on both the root and the leaf command found via Find(); setting it on rootCmd silences the usage dump for every subcommand's error, matching the existing per-command opt-in already used in format.go/remember_batch.go but applied globally.
7/7 PASS. Self-merge authorized under the reinstated standing
authorization (mayor ruling gm-wisp-2yhv7u).
@quad341
quad341 merged commit 93c2593 into main Aug 20, 2026
2 checks passed
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.

1 participant