From e6b71486b050c408f07f0ff06bb5b267e8830c15 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Tue, 6 Oct 2020 13:13:52 -0400 Subject: [PATCH] modify version command to match grype (#196) Signed-off-by: Alex Goodman --- cmd/version.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/cmd/version.go b/cmd/version.go index c4897452e..8ceddca02 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -12,7 +12,6 @@ import ( "github.com/spf13/cobra" ) -var showVerboseVersionInfo bool var outputFormat string var versionCmd = &cobra.Command{ @@ -22,7 +21,6 @@ var versionCmd = &cobra.Command{ } func init() { - versionCmd.Flags().BoolVarP(&showVerboseVersionInfo, "verbose", "v", false, "show additional version information") versionCmd.Flags().StringVarP(&outputFormat, "output", "o", string(presenter.TextPresenter), "format to show version information (available=[text, json])") rootCmd.AddCommand(versionCmd) } @@ -32,18 +30,15 @@ func printVersion(_ *cobra.Command, _ []string) { switch outputFormat { case "text": - if showVerboseVersionInfo { - fmt.Println("Application: ", internal.ApplicationName) - fmt.Println("Version: ", versionInfo.Version) - fmt.Println("BuildDate: ", versionInfo.BuildDate) - fmt.Println("GitCommit: ", versionInfo.GitCommit) - fmt.Println("GitTreeState: ", versionInfo.GitTreeState) - fmt.Println("Platform: ", versionInfo.Platform) - fmt.Println("GoVersion: ", versionInfo.GoVersion) - fmt.Println("Compiler: ", versionInfo.Compiler) - } else { - fmt.Printf("%s %s\n", internal.ApplicationName, versionInfo.Version) - } + fmt.Println("Application: ", internal.ApplicationName) + fmt.Println("Version: ", versionInfo.Version) + fmt.Println("BuildDate: ", versionInfo.BuildDate) + fmt.Println("GitCommit: ", versionInfo.GitCommit) + fmt.Println("GitTreeState: ", versionInfo.GitTreeState) + fmt.Println("Platform: ", versionInfo.Platform) + fmt.Println("GoVersion: ", versionInfo.GoVersion) + fmt.Println("Compiler: ", versionInfo.Compiler) + case "json": enc := json.NewEncoder(os.Stdout) enc.SetEscapeHTML(false)