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

Fix format=json being initialized #22

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,18 @@ func (c *cli) init() error {
}
c.renderer.Tenant = c.tenant

// Determine what the desired output format is.
format := strings.ToLower(c.format)
if format != "" && format != string(display.OutputFormatJSON) {
c.errOnce = fmt.Errorf("Invalid format. Use `--format=json` or omit this option to use the default format.")
return
}
c.renderer.Format = display.OutputFormat(format)
})

// Determine what the desired output format is.
//
// NOTE(cyx): Since this isn't expensive to do, we don't need to put it
// inside initOnce.
format := strings.ToLower(c.format)
if format != "" && format != string(display.OutputFormatJSON) {
return fmt.Errorf("Invalid format. Use `--format=json` or omit this option to use the default format.")
}
c.renderer.Format = display.OutputFormat(format)

// Once initialized, we'll keep returning the same err that was
// originally encountered.
return c.errOnce
Expand Down