Skip to content

Commit 5a359d5

Browse files
committed
cmd/cue: add more test cases for unknown flags and commands
In particular, combining an unknown mod sub-command with an unknown flag causes us to fail with the unknown flag, which is confusing. For #3810. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ib7357526176e69f73da00eebf4c604d0ff65e659 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211265 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
1 parent cbb205e commit 5a359d5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cmd/cue/cmd/testdata/script/unknown_args.txtar

+27
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@ cmp stderr unknown_cmd.out
66
! stdout .
77
cmp stderr unknown_flag.out
88

9+
! exec cue unknown --unknown
10+
! stdout .
11+
cmp stderr unknown_cmd.out
12+
13+
! exec cue mod unknown
14+
! stdout .
15+
cmp stderr unknown_mod_cmd.out
16+
17+
! exec cue mod --unknown
18+
! stdout .
19+
cmp stderr unknown_flag.out
20+
21+
# TODO: this should result in an "unknown subcommand" error.
22+
! exec cue mod unknown --unknown
23+
! stdout .
24+
cmp stderr unknown_flag.out
25+
26+
# A rather convoluted edge case, but Cobra allows mixing flags with args,
27+
# even when the args are subcommand names. -v and -E are global flags.
28+
# TODO: this should result in an "unknown subcommand" error.
29+
! exec cue -v mod -E unknown --unknown
30+
! stdout .
31+
cmp stderr unknown_flag.out
32+
933
! exec cue evla
1034
! stdout .
1135
cmp stderr typo_cmd.stdout
1236

1337
-- unknown_cmd.out --
1438
unknown command "unknown" for "cue"
39+
-- unknown_mod_cmd.out --
40+
mod must be run as one of its subcommands: unknown subcommand "unknown"
41+
Run 'cue help mod' for known subcommands.
1542
-- unknown_flag.out --
1643
unknown flag: --unknown
1744
-- typo_cmd.stdout --

0 commit comments

Comments
 (0)