Skip to content
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

unknown command is printed twice #744

Closed
yoni386 opened this issue Sep 12, 2018 · 3 comments
Closed

unknown command is printed twice #744

yoni386 opened this issue Sep 12, 2018 · 3 comments

Comments

@yoni386
Copy link

yoni386 commented Sep 12, 2018

Default output for "unknown command" is getting printed two times.

For example:
The command is given command is "pri1" and the actual one is "print"

subcommand pri1 return 
Error: unknown command "pri1" for "hoster"

Did you mean this?
        print

Run 'hoster --help' for usage.
unknown command "pri1" for "hoster"

Did you mean this?
        print

@lornajane
Copy link

This happens because the error is output both when it happens https://github.com/spf13/cobra/blob/master/command.go#L841-L842 and probably in your cmd/root.go also. Removing fmt.Println(err) from my Execute() function in the root command has stopped this showing twice but if any other error is returned, it won't be output so this might not be the best solution!

@github-actions
Copy link

github-actions bot commented Apr 9, 2020

This issue is being marked as stale due to a long period of inactivity

@johnSchnake
Copy link
Collaborator

You can also disable cobra from automatically printing the error or usage messages.

Closing as part of #1600.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants