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

Commit e6ba410

Browse files
Merge pull request #646 from glours/cmd_error_message_like_cli
unknow command - use the same error format as the Docker CLI
2 parents b785c27 + 1f9b31e commit e6ba410

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
@@ -41,16 +41,12 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
4141
return cmd.GenZshCompletion(dockerCli.Out())
4242
default:
4343
if completion != "" {
44-
fmt.Printf("%q is not a supported shell", completion)
45-
cmd.HelpFunc()(cmd, args)
46-
os.Exit(1)
44+
return fmt.Errorf("%q is not a supported shell\nSee 'docker app --help'", completion)
4745
}
4846
}
4947

5048
if len(args) != 0 {
51-
fmt.Printf("%q is not a docker app command", args[0])
52-
cmd.HelpFunc()(cmd, args)
53-
os.Exit(1)
49+
return fmt.Errorf("%q is not a docker app command\nSee 'docker app --help'", args[0])
5450
}
5551
cmd.HelpFunc()(cmd, args)
5652
return nil

0 commit comments

Comments
 (0)