Skip to content

Commit

Permalink
cmd/cue: add a test case for cue cmd foo args -t tag
Browse files Browse the repository at this point in the history
`cue help cmd` says:

    Usage:
      cue cmd <name> [inputs] [flags]

So it is perfectly reasonable for end users to try writing flags
for `cue cmd` after all arguments. Or, for example, former users of
the short form like `cue foo args -t tag` may just want to add "cmd"
as a second argument without reordering the arguments and flags.

This currently does not work, as can be seen from the added test.
The following commit will change this.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I227c0d35b8153a50ccfc99f03413730c3ceef7c3
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206783
Reviewed-by: Paul Jolly <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mvdan committed Jan 6, 2025
1 parent d8fabe1 commit d182fc2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/cue/cmd/testdata/script/cmd_tags.txtar
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
exec cue cmd -t prod -t name=bar tag tags.cue tags_tool.cue
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"'

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

0 comments on commit d182fc2

Please sign in to comment.