grype/cmd/version.go

35 lines
525 B
Go
Raw Normal View History

2020-05-26 14:37:28 +00:00
package cmd
import (
"fmt"
"github.com/anchore/vulnscan/internal"
"github.com/spf13/cobra"
)
type Version struct {
Version string
Commit string
BuildTime string
}
var version *Version
var versionCmd = &cobra.Command{
Use: "version",
Short: "show the version",
2020-05-26 17:31:50 +00:00
Run: runVersionCmd,
2020-05-26 14:37:28 +00:00
}
func init() {
rootCmd.AddCommand(versionCmd)
}
func SetVersion(v *Version) {
version = v
}
2020-05-26 17:31:50 +00:00
func runVersionCmd(cmd *cobra.Command, args []string) {
2020-05-26 14:37:28 +00:00
fmt.Printf("%s %s\n", internal.ApplicationName, version.Version)
}