Skip to content

Commit

Permalink
fix: default output format not set properly
Browse files Browse the repository at this point in the history
I was setting the wrong property in contradiction with
the logic around default output format

fixes: #1
  • Loading branch information
davidalpert committed Nov 19, 2023
1 parent 823f4a1 commit 771f65c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions v1/printer_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (o *PrinterOptions) WithStreams(s IOStreams) *PrinterOptions {

// WithDefaultOutput sets a default output format if one is not provided through a flag value
func (o *PrinterOptions) WithDefaultOutput(output string) *PrinterOptions {
o.OutputFormat = &output
o.DefaultOutputFormat = &output
return o
}

Expand Down Expand Up @@ -100,13 +100,13 @@ func (o *PrinterOptions) AddPrinterFlags(c *pflag.FlagSet) {
// AddObjectPrinterFlags adds flags to a cobra.Command
func (o *PrinterOptions) addObjectPrinterFlags(c *pflag.FlagSet) {
if o.OutputFormat != nil {
c.StringVarP(o.OutputFormat, "output", "o", *o.OutputFormat, fmt.Sprintf("output format: one of %s.", strings.Join(supportedObjectPrinterCategories, "|")))
c.StringVarP(o.OutputFormat, "output", "o", *o.DefaultOutputFormat, fmt.Sprintf("output format: one of %s.", strings.Join(supportedObjectPrinterCategories, "|")))
}
}

// AddListPrinterFlags adds flags to a cobra.Command
func (o *PrinterOptions) addListPrinterFlags(c *pflag.FlagSet) {
if o.OutputFormat != nil {
c.StringVarP(o.OutputFormat, "output", "o", *o.OutputFormat, fmt.Sprintf("output format: one of %s.", strings.Join(supportedListPrinterCategories, "|")))
c.StringVarP(o.OutputFormat, "output", "o", *o.DefaultOutputFormat, fmt.Sprintf("output format: one of %s.", strings.Join(supportedListPrinterCategories, "|")))
}
}

0 comments on commit 771f65c

Please sign in to comment.