Skip to content

Commit f3d37f5

Browse files
author
Paolo Calao
authored
Add yaml and jsonmini output formats (#90)
1 parent 003994d commit f3d37f5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cli/cli.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func Execute() {
5656
cli.AddCommand(ota.NewCommand())
5757

5858
cli.PersistentFlags().BoolVarP(&cliFlags.verbose, "verbose", "v", false, "Print the logs on the standard output.")
59-
cli.PersistentFlags().StringVar(&cliFlags.outputFormat, "format", "text", "The output format, can be {text|json}.")
59+
validOutputFormats := []string{"text", "json", "jsonmini", "yaml"}
60+
cli.PersistentFlags().StringVar(&cliFlags.outputFormat, "format", "text",
61+
fmt.Sprintf("The output format, can be: %s", strings.Join(validOutputFormats, ", ")),
62+
)
6063

6164
if err := cli.Execute(); err != nil {
6265
fmt.Fprintln(os.Stderr, err)
@@ -65,9 +68,11 @@ func Execute() {
6568

6669
func parseFormatString(arg string) (feedback.OutputFormat, bool) {
6770
f, found := map[string]feedback.OutputFormat{
68-
"json": feedback.JSON,
69-
"text": feedback.Text,
70-
}[arg]
71+
"json": feedback.JSON,
72+
"jsonmini": feedback.JSONMini,
73+
"text": feedback.Text,
74+
"yaml": feedback.YAML,
75+
}[strings.ToLower(arg)]
7176

7277
return f, found
7378
}

0 commit comments

Comments
 (0)