Skip to content

Commit

Permalink
Fix [flags] appearing at end of usage
Browse files Browse the repository at this point in the history
Turns out Cobra searches your usage line for the specific text "[flags]"
and if it doesn't find it, shoves it on the end. Gross. For that reason,
let's remove explicit callout of any flags and move it back to *before*
the double-hyphen.
  • Loading branch information
annettejanewilson committed Jun 4, 2024
1 parent 8875ffa commit 91dfe89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/foreach/foreach.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func formatArguments(arguments []string) string {

func NewForeachCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "foreach [--repos REPOFILE] -- COMMAND [ARGUMENT...]",
Use: "foreach [flags] -- COMMAND [ARGUMENT...]",
Short: "Run COMMAND against each working copy",
Long:
`Run COMMAND against each working copy. Make sure to include a
Expand Down
2 changes: 1 addition & 1 deletion cmd/foreach/foreach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestHelpFlagReturnsUsage(t *testing.T) {
assert.NoError(t, err)
// should return usage
assert.Contains(t, out, "Usage:")
assert.Contains(t, out, "foreach [--repos REPOFILE] -- COMMAND [ARGUMENT...]")
assert.Contains(t, out, "foreach [flags] -- COMMAND [ARGUMENT...]")
assert.Contains(t, out, "Flags:")
assert.Contains(t, out, "help for foreach")

Expand Down

0 comments on commit 91dfe89

Please sign in to comment.