diff --git a/cmd/cue/cmd/cmd.go b/cmd/cue/cmd/cmd.go index 87340b5c9..0f59756ad 100644 --- a/cmd/cue/cmd/cmd.go +++ b/cmd/cue/cmd/cmd.go @@ -175,6 +175,10 @@ Run "cue help commands" for more details on tasks and commands. } // Presumably the *cobra.Command argument should be cmd.Command, // as that is the one which will have the right settings applied. + if isRootCmd { + cmd.PrintErrf("The short-form 'cue %[1]s' is deprecated; use 'cue cmd %[1]s'.\n", args[0]) + cmd.PrintErrf("See: https://cuelang.org/issue/2519\n") + } return sub.RunE(cmd.Command, args[1:]) }), } diff --git a/cmd/cue/cmd/testdata/script/cmd_embed.txtar b/cmd/cue/cmd/testdata/script/cmd_embed.txtar index b74a3cd8d..6db206eaa 100644 --- a/cmd/cue/cmd/testdata/script/cmd_embed.txtar +++ b/cmd/cue/cmd/testdata/script/cmd_embed.txtar @@ -4,11 +4,11 @@ exec cue export cmp stdout expect/concrete.json # Using the explicitly written command works OK. -exec cue hello1 +exec cue cmd hello1 stdout 'hello, world' # Using the command that's defined externally fails. -exec cue hello +exec cue cmd hello stdout 'hello, world' diff --git a/cmd/cue/cmd/testdata/script/cmd_func.txtar b/cmd/cue/cmd/testdata/script/cmd_func.txtar index 7921b3c67..0bc7a3722 100644 --- a/cmd/cue/cmd/testdata/script/cmd_func.txtar +++ b/cmd/cue/cmd/testdata/script/cmd_func.txtar @@ -1,5 +1,5 @@ # Issue #578 -exec cue dump ./... +exec cue cmd dump ./... cmp stdout stdout-expect -- k1.cue -- package kube diff --git a/cmd/cue/cmd/testdata/script/cmd_short.txtar b/cmd/cue/cmd/testdata/script/cmd_short.txtar new file mode 100644 index 000000000..d55529ec3 --- /dev/null +++ b/cmd/cue/cmd/testdata/script/cmd_short.txtar @@ -0,0 +1,19 @@ +exec cue cmd hello +stdout 'Hello world!' +! stderr . + +exec cue hello +stdout 'Hello world!' +cmp stderr stderr-warning + +-- stderr-warning -- +The short-form 'cue hello' is deprecated; use 'cue cmd hello'. +See: https://cuelang.org/issue/2519 +-- task_tool.cue -- +package home + +import "tool/cli" + +command: hello: cli.Print & { + text: "Hello world!" +}