-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add json flag for ctc_lib. #593
Conversation
if displayError != nil { | ||
Log.Errorf("%v", commandError) | ||
} | ||
if commandError != nil && displayError != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to ||
@@ -74,6 +74,9 @@ func (ctb *ContainerToolCommandBase) AddSubCommands() { | |||
|
|||
// Set up Root Command | |||
ctb.Command.SetHelpTemplate(HelpTemplate) | |||
|
|||
// Donot display usage when using RunE | |||
ctb.SilenceUsage = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spf13/cobra#340 issue link to why we need to force this to be true.
LogIfErr(totalError, Log) | ||
|
||
if commandError != nil && totalError != nil { | ||
return errors.New("One or more errors") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are errors handled the same way if json output is used? It might be worth adding some test cases for failing commands as well in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add tests in this PR :) Thanks @aaron-prindle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left one comment
No description provided.