Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 1f9b31e

Browse files
committed
unknow command - use the same error format as the Docker CLI
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 695509b commit 1f9b31e

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

e2e/commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestExitErrorCode(t *testing.T) {
2727
cmd.Command = dockerCli.Command("app", "unknown_command")
2828
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
2929
ExitCode: 1,
30-
Out: "\"unknown_command\" is not a docker app command",
30+
Err: "\"unknown_command\" is not a docker app command\nSee 'docker app --help'",
3131
})
3232
}
3333

internal/commands/root.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
3838
return cmd.GenZshCompletion(dockerCli.Out())
3939
default:
4040
if completion != "" {
41-
fmt.Printf("%q is not a supported shell", completion)
42-
cmd.HelpFunc()(cmd, args)
43-
os.Exit(1)
41+
return fmt.Errorf("%q is not a supported shell\nSee 'docker app --help'", completion)
4442
}
4543
}
4644

4745
if len(args) != 0 {
48-
fmt.Printf("%q is not a docker app command", args[0])
49-
cmd.HelpFunc()(cmd, args)
50-
os.Exit(1)
46+
return fmt.Errorf("%q is not a docker app command\nSee 'docker app --help'", args[0])
5147
}
5248
cmd.HelpFunc()(cmd, args)
5349
return nil

0 commit comments

Comments
 (0)