Skip to content

Commit e8ecf23

Browse files
committed
cmd/cue: deprecate cue somecmd in favor of cue cmd somecmd
v0.9.0-alpha.1 will be released with the deprecation warning to stderr, and a future release like v0.10 or v0.11 can remove support entirely. Note that even when we remove support for the short form, this shouldn't be a hard breakage for any users, as they can switch to the long form by adding the "cmd" argument. Also rewrite a few tests which didn't need to use the short form. Only one other test case remains with the short form, as it explicitly tests for an edge case bug relating to the short form. That test case can be removed entirely once we drop support. Updates #2519. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I04aa48b048bb3f1c397f8b95a36933d797734930 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1185473 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Paul Jolly <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent ec655a5 commit e8ecf23

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

cmd/cue/cmd/cmd.go

+4
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Run "cue help commands" for more details on tasks and commands.
175175
}
176176
// Presumably the *cobra.Command argument should be cmd.Command,
177177
// as that is the one which will have the right settings applied.
178+
if isRootCmd {
179+
cmd.PrintErrf("The short-form 'cue %[1]s' is deprecated; use 'cue cmd %[1]s'.\n", args[0])
180+
cmd.PrintErrf("See: https://cuelang.org/issue/2519\n")
181+
}
178182
return sub.RunE(cmd.Command, args[1:])
179183
}),
180184
}

cmd/cue/cmd/testdata/script/cmd_embed.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ exec cue export
44
cmp stdout expect/concrete.json
55

66
# Using the explicitly written command works OK.
7-
exec cue hello1
7+
exec cue cmd hello1
88
stdout 'hello, world'
99

1010
# Using the command that's defined externally fails.
11-
exec cue hello
11+
exec cue cmd hello
1212
stdout 'hello, world'
1313

1414

cmd/cue/cmd/testdata/script/cmd_func.txtar

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Issue #578
2-
exec cue dump ./...
2+
exec cue cmd dump ./...
33
cmp stdout stdout-expect
44
-- k1.cue --
55
package kube
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
exec cue cmd hello
2+
stdout 'Hello world!'
3+
! stderr .
4+
5+
exec cue hello
6+
stdout 'Hello world!'
7+
cmp stderr stderr-warning
8+
9+
-- stderr-warning --
10+
The short-form 'cue hello' is deprecated; use 'cue cmd hello'.
11+
See: https://cuelang.org/issue/2519
12+
-- task_tool.cue --
13+
package home
14+
15+
import "tool/cli"
16+
17+
command: hello: cli.Print & {
18+
text: "Hello world!"
19+
}

0 commit comments

Comments
 (0)