Skip to content

Commit

Permalink
cmd/cue: allow interspersed flags in cue cmd
Browse files Browse the repository at this point in the history
All of our commands allow this as it is a default in cobra,
but we disallowed mixing flags and arguments in `cue cmd` since
the first flag was added via https://cue-review.googlesource.com/c/cue/+/4949.

There wasn't any justification to the restriction in the commit message
or code, and there aren't any tests which break when removing the line.

Moreover, `cue foo . -t tag` worked as a shortcut command before,
perhaps by accident due to how we implemented short commands,
so it doesn't make any sense for `cue cmd foo . -t tag` to now fail.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I9119e7205bf778be7d03f57fa8a22338bf3d6e5a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206784
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
mvdan committed Jan 6, 2025
1 parent d182fc2 commit e41efd5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions cmd/cue/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ Run "cue help commands" for more details on tasks and workflow commands.
}),
}

cmd.Flags().SetInterspersed(false)

addInjectionFlags(cmd.Flags(), true, false)

return cmd
Expand Down
4 changes: 2 additions & 2 deletions cmd/cue/cmd/testdata/script/cmd_tags.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cmp stdout expect-stdout

# Check that the flags can be used after any arguments;
# such "interspersed" flags are supported by cobra by default.
! exec cue cmd tag tags.cue tags_tool.cue -t prod -t name=bar
stderr 'no encoding specified for file "-t"'
exec cue cmd tag tags.cue tags_tool.cue -t prod -t name=bar
cmp stdout expect-stdout

# Verify that the new global -t flag added as a fix for issue 2510 above
# works with the explicit or implicit "cmd" sub-command,
Expand Down

0 comments on commit e41efd5

Please sign in to comment.