firefly-cli
firefly-cli copied to clipboard
Usage info should not be dumped for errors that don't relate to usage
The "usage" info for the active CLI command is always dumped when an error is encountered. This should only be dumped for errors that stem from invalid syntax, not from functional errors executing the command.
This is a good suggestion. The reason it works the way it does is that any error returned from a Cobra RunE() will print usage by default. So we'll need to handle errors at the top level differently.
I can pickup this one.
Here's my finding: We need to suppress usage info for internal errors with cmd.SilenceUsage = true and not call the cobra.CheckErr() function here explicitly https://github.com/hyperledger/firefly-cli/blob/main/cmd/root.go#L85 as it results in printing the error message twice.
When there is an error, cobra library prints the error message by default.