Add a default value to the new --format option
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
5323fcb513
commit
f9abb30128
2 changed files with 8 additions and 8 deletions
|
|
@ -39,8 +39,8 @@ var (
|
|||
needsInit bool
|
||||
debug bool
|
||||
poolBalancerType string
|
||||
outputFormat common.OutputFormat
|
||||
errNeedsInitError = fmt.Errorf("please log into a garm installation first")
|
||||
outputFormat common.OutputFormat = common.OutputFormatTable
|
||||
errNeedsInitError = fmt.Errorf("please log into a garm installation first")
|
||||
)
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
|
|
@ -55,9 +55,6 @@ var rootCmd = &cobra.Command{
|
|||
func Execute() {
|
||||
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable debug on all API calls")
|
||||
rootCmd.PersistentFlags().VarP(&outputFormat, "format", "f", "Output format (table, json)")
|
||||
if outputFormat.String() == "" {
|
||||
outputFormat = common.OutputFormatTable
|
||||
}
|
||||
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@ const (
|
|||
OutputFormatJSON OutputFormat = "json"
|
||||
)
|
||||
|
||||
func (o OutputFormat) String() string {
|
||||
return string(o)
|
||||
func (o *OutputFormat) String() string {
|
||||
if o == nil {
|
||||
return ""
|
||||
}
|
||||
return string(*o)
|
||||
}
|
||||
|
||||
func (o *OutputFormat) Set(value string) error {
|
||||
|
|
@ -23,6 +26,6 @@ func (o *OutputFormat) Set(value string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (o OutputFormat) Type() string {
|
||||
func (o *OutputFormat) Type() string {
|
||||
return "string"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue