This change adds a --format command line option to the GARM cli. This option accepts either json or table as a value. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
28 lines
467 B
Go
28 lines
467 B
Go
package common
|
|
|
|
import "fmt"
|
|
|
|
type OutputFormat string
|
|
|
|
const (
|
|
OutputFormatTable OutputFormat = "table"
|
|
OutputFormatJSON OutputFormat = "json"
|
|
)
|
|
|
|
func (o OutputFormat) String() string {
|
|
return string(o)
|
|
}
|
|
|
|
func (o *OutputFormat) Set(value string) error {
|
|
switch value {
|
|
case "table", "json":
|
|
*o = OutputFormat(value)
|
|
default:
|
|
return fmt.Errorf("allowed formats are: json, table")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (o OutputFormat) Type() string {
|
|
return "string"
|
|
}
|