Skip to content

Commit 07f807b

Browse files
authored
fix: suppress help output on runtime errors (#41)
Cobra prints usage/help text by default when `RunE` returns an error. This meant any runtime error (e.g. a rebase conflict during `restack`) would dump a wall of irrelevant help output before the actual error message. Set `SilenceUsage: true` on the root command so help is only shown for actual usage errors. Closes #35
1 parent c31fa5c commit 07f807b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cmd/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ var rootCmd = &cobra.Command{
1616
Use: "gh-stack",
1717
Short: "Manage stacked pull requests",
1818
Long: `gh-stack tracks parent-child relationships between branches, enabling workflows where PRs target other PRs.`,
19+
// SilenceUsage prevents Cobra from printing the help/usage text when a
20+
// command's RunE returns an error. Without this, any runtime error
21+
// (e.g. a rebase conflict) causes the full usage output to be shown,
22+
// which is confusing and unhelpful.
23+
SilenceUsage: true,
1924
}
2025

2126
// Execute runs the root command.

0 commit comments

Comments
 (0)