From cc57970427db8b7760f30a49360e068cc50f75ee Mon Sep 17 00:00:00 2001 From: Paolo Calao Date: Mon, 20 Dec 2021 16:34:11 +0100 Subject: [PATCH] Add yaml and jsonmini output formats --- cli/cli.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 7b9a8267..b26ed8b0 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -56,7 +56,10 @@ func Execute() { cli.AddCommand(ota.NewCommand()) cli.PersistentFlags().BoolVarP(&cliFlags.verbose, "verbose", "v", false, "Print the logs on the standard output.") - cli.PersistentFlags().StringVar(&cliFlags.outputFormat, "format", "text", "The output format, can be {text|json}.") + validOutputFormats := []string{"text", "json", "jsonmini", "yaml"} + cli.PersistentFlags().StringVar(&cliFlags.outputFormat, "format", "text", + fmt.Sprintf("The output format, can be: %s", strings.Join(validOutputFormats, ", ")), + ) if err := cli.Execute(); err != nil { fmt.Fprintln(os.Stderr, err) @@ -65,9 +68,11 @@ func Execute() { func parseFormatString(arg string) (feedback.OutputFormat, bool) { f, found := map[string]feedback.OutputFormat{ - "json": feedback.JSON, - "text": feedback.Text, - }[arg] + "json": feedback.JSON, + "jsonmini": feedback.JSONMini, + "text": feedback.Text, + "yaml": feedback.YAML, + }[strings.ToLower(arg)] return f, found }