-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate output - probably in error cases #1415
Comments
We are observing this behavior as well with a bare-bones setup for a new CLI app my team is working on. using More info: Error: [error msg] [Usage info] [error msg] It's as if whatever method or template is being used in both cases is accidentally calling the error string a second time. |
func Execute() {
cobra.CheckErr(rootCmd.Execute())
} removing the func Execute() {
rootCmd.Execute()
} resulting in:
but the program exits with status code 0, and i use this to fix reflect the correct exit status code func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
} |
This issue is being marked as stale due to a long period of inactivity |
If error then return. This fix two things, one, a duplicate unknown command (see this spf13/cobra#1415), second, unnecesary exit(1) on command line
* Switch back to cobra * Replace coral with cobra * Remove Log.Panic If error then return. This fix two things, one, a duplicate unknown command (see this spf13/cobra#1415), second, unnecesary exit(1) on command line
Versions
go version go1.16.4 linux/amd64
cobra 1.1.3
How to reproduce?
Generate a new project with
cobra init --pkg-name doublecheck
.Generate a new command with
cobra add version
.Build the project or use
go run
.Output
Test with unknown command:
Expected behavior
No double messages
The text was updated successfully, but these errors were encountered: