Skip to content

Commit 91dfe89

Browse files
Fix [flags] appearing at end of usage
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.
1 parent 8875ffa commit 91dfe89

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cmd/foreach/foreach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func formatArguments(arguments []string) string {
4747

4848
func NewForeachCmd() *cobra.Command {
4949
cmd := &cobra.Command{
50-
Use: "foreach [--repos REPOFILE] -- COMMAND [ARGUMENT...]",
50+
Use: "foreach [flags] -- COMMAND [ARGUMENT...]",
5151
Short: "Run COMMAND against each working copy",
5252
Long:
5353
`Run COMMAND against each working copy. Make sure to include a

cmd/foreach/foreach_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func TestHelpFlagReturnsUsage(t *testing.T) {
131131
assert.NoError(t, err)
132132
// should return usage
133133
assert.Contains(t, out, "Usage:")
134-
assert.Contains(t, out, "foreach [--repos REPOFILE] -- COMMAND [ARGUMENT...]")
134+
assert.Contains(t, out, "foreach [flags] -- COMMAND [ARGUMENT...]")
135135
assert.Contains(t, out, "Flags:")
136136
assert.Contains(t, out, "help for foreach")
137137

0 commit comments

Comments
 (0)