Skip to content

return non-zero exit code upon non-runnable subcommand #1156

@donggangcj

Description

@donggangcj

when excuting a root comand , cobra returns success on typos and exit code is 1.

➜  ~ helm notfoundsubcommand
Error: unknown command "notfoundsubcommand" for "helm"
Run 'helm --help' for usage.
➜  ~ echo $?
1

when excuting a subcommand ,cobra returns success on typos but exit code is 0.

➜  ~ helm repo sadd foo https://foo/bar

This command consists of multiple subcommands to interact with chart repositories.

It can be used to add, remove, list, and index chart repositories.

Usage:
  helm repo [command]

Available Commands:
  add         add a chart repository
....

➜  ~ echo $?
0

This issue has come up before and this is related pr.

The related helm pr is here.

Metadata

Metadata

Assignees

Labels

area/cobra-commandCore `cobra.Command` implementationskind/bugA bug in cobra; unintended behaviortriage/needs-infoNeeds more investigation from maintainers or more info from the issue provider

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions