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
cmp stdout expect-stdout

# Verify that the global -t flag works with commands like "cmd"
# or "eval", but not "fmt".
exec cue -t prod -t name=bar cmd tag tags.cue tags_tool.cue
cmp stdout expect-stdout
exec cue eval -t name=bar tags.cue
stdout 'name: *"bar"'
exec cue -t name=bar eval tags.cue
stdout 'name: *"bar"'
! exec cue fmt -t name=bar tags.cue
stderr 'unknown shorthand flag'
! exec cue -t name=bar fmt tags.cue
stderr 'unknown shorthand flag'

-- expect-stdout --
prod: bar
-- tags.cue --
package tags

var: env: "prod" | "staging" @tag(env,short=prod|staging)
var: name: string  @tag(name)

-- tags_tool.cue --
package tags

import "tool/cli"

command: tag: cli.Print & {
    text: "\(var.env): \(var.name)"
}
