modify version command to match grype (#196)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2020-10-06 13:13:52 -04:00 committed by GitHub
parent 5adfce19e0
commit e6b71486b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var showVerboseVersionInfo bool
var outputFormat string var outputFormat string
var versionCmd = &cobra.Command{ var versionCmd = &cobra.Command{
@ -22,7 +21,6 @@ var versionCmd = &cobra.Command{
} }
func init() { 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])") versionCmd.Flags().StringVarP(&outputFormat, "output", "o", string(presenter.TextPresenter), "format to show version information (available=[text, json])")
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)
} }
@ -32,7 +30,6 @@ func printVersion(_ *cobra.Command, _ []string) {
switch outputFormat { switch outputFormat {
case "text": case "text":
if showVerboseVersionInfo {
fmt.Println("Application: ", internal.ApplicationName) fmt.Println("Application: ", internal.ApplicationName)
fmt.Println("Version: ", versionInfo.Version) fmt.Println("Version: ", versionInfo.Version)
fmt.Println("BuildDate: ", versionInfo.BuildDate) fmt.Println("BuildDate: ", versionInfo.BuildDate)
@ -41,9 +38,7 @@ func printVersion(_ *cobra.Command, _ []string) {
fmt.Println("Platform: ", versionInfo.Platform) fmt.Println("Platform: ", versionInfo.Platform)
fmt.Println("GoVersion: ", versionInfo.GoVersion) fmt.Println("GoVersion: ", versionInfo.GoVersion)
fmt.Println("Compiler: ", versionInfo.Compiler) fmt.Println("Compiler: ", versionInfo.Compiler)
} else {
fmt.Printf("%s %s\n", internal.ApplicationName, versionInfo.Version)
}
case "json": case "json":
enc := json.NewEncoder(os.Stdout) enc := json.NewEncoder(os.Stdout)
enc.SetEscapeHTML(false) enc.SetEscapeHTML(false)