cmd/cue: fix regression when injecting vars with cue cmd
The -t and -T flags can be used like:
cue cmd -t foo=var -T mycmd .
However, we also support a short form, where "cmd" can be omitted:
cue -t foo=var -T mycmd .
After the refactor in https://cuelang.org/cl/552733,
we made cmd/cue more principled in how it handles the root command,
and we broke those -t and -T flags in the "cue cmd" short form.
We didn't intend to - they just started being treated as global flags.
A simple and easy fix is to actually declare these flags globally,
and not just as part of the "cue cmd" sub-command.
Since each of these flags now exists in two levels,
the only place where they are consumed, the setTags function,
now checks both flag sets and joins their values.
Note that we make the new global flags hidden,
so that "cue help" doesn't start showing them as global flags.
We don't really intend them as global flags for every command.
We also avoid adding them to PersistentFlags,
so that they are not inherited by sub-commands like fmt.
This fix is preferrable to an entire revert of the previous CL,
as otherwise commands like "cue help" would become very slow again.
I've also filed #2519 to propose deprecating the "cue cmd" short form.
Fixes #2510.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I254e1c4e8ef4d6ffa7d6142c75abee5f1a37a810
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557127
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>