Skip to content

Commit

Permalink
cmd/cue: enable subcommand suggestions when a user makes a typo
Browse files Browse the repository at this point in the history
We had disabled this a while back due to `cue foo` being allowed
as a shortcut to `cue cmd foo`. Since all the `cmd` subcommands
were not known upfront by cobra, any suggestions it made would be
missing information and potentially confuse users.

Since https://cuelang.org/issue/2519 was closed by removing support
for the deprecated `cue foo` short form, we can re-enable this now.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I9bfa385f5d1e68413d147123d0861ce27383f69a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1204874
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
mvdan committed Nov 28, 2024
1 parent 70e5273 commit e11cbfb
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 0 additions & 5 deletions cmd/cue/cmd/root.go
Original file line number Diff line number Diff line change
@@ -204,11 +204,6 @@ func New(args []string) (*Command, error) {
// We can explicitly trigger help on certain errors via pflag.ErrHelp.
SilenceErrors: true,
SilenceUsage: true,

// We currently support top-level custom commands like `cue mycmd` as an alias
// for `cue cmd mycmd`, so any sub-command suggestions might be confusing.
// TODO(mvdan): remove this and test it, as we no longer support `cue mycmd`.
DisableSuggestions: true,
}

c := &Command{
4 changes: 4 additions & 0 deletions cmd/cue/cmd/testdata/script/unknown_args.txtar
Original file line number Diff line number Diff line change
@@ -16,3 +16,7 @@ unknown command "unknown" for "cue"
unknown flag: --unknown
-- typo_cmd.stdout --
unknown command "evla" for "cue"

Did you mean this?
eval

0 comments on commit e11cbfb

Please sign in to comment.