Skip to content

Commit

Permalink
cmd/cue: deprecate cue somecmd in favor of cue cmd somecmd
Browse files Browse the repository at this point in the history
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í <mvdan@mvdan.cc>
Change-Id: I04aa48b048bb3f1c397f8b95a36933d797734930
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1185473
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@gmail.com>
  • Loading branch information
mvdan committed Mar 21, 2024
1 parent ec655a5 commit e8ecf23
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/cue/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:])
}),
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cue/cmd/testdata/script/cmd_embed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down
2 changes: 1 addition & 1 deletion cmd/cue/cmd/testdata/script/cmd_func.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Issue #578
exec cue dump ./...
exec cue cmd dump ./...
cmp stdout stdout-expect
-- k1.cue --
package kube
Expand Down
19 changes: 19 additions & 0 deletions cmd/cue/cmd/testdata/script/cmd_short.txtar
Original file line number Diff line number Diff line change
@@ -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!"
}

0 comments on commit e8ecf23

Please sign in to comment.