mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
Add a version flag (#722)
This commit is contained in:
parent
211b188120
commit
7168dc7473
@ -4,7 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/internal"
|
||||||
"github.com/anchore/syft/internal/config"
|
"github.com/anchore/syft/internal/config"
|
||||||
|
"github.com/anchore/syft/internal/version"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
@ -22,12 +24,14 @@ var rootCmd = &cobra.Command{
|
|||||||
PreRunE: packagesCmd.PreRunE,
|
PreRunE: packagesCmd.PreRunE,
|
||||||
RunE: packagesCmd.RunE,
|
RunE: packagesCmd.RunE,
|
||||||
ValidArgsFunction: packagesCmd.ValidArgsFunction,
|
ValidArgsFunction: packagesCmd.ValidArgsFunction,
|
||||||
|
Version: version.FromBuild().Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// set universal flags
|
// set universal flags
|
||||||
rootCmd.PersistentFlags().StringVarP(&persistentOpts.ConfigPath, "config", "c", "", "application config file")
|
rootCmd.PersistentFlags().StringVarP(&persistentOpts.ConfigPath, "config", "c", "", "application config file")
|
||||||
|
// setting the version template to just print out the string since we already have a templatized version string
|
||||||
|
rootCmd.SetVersionTemplate(fmt.Sprintf("%s {{.Version}}\n", internal.ApplicationName))
|
||||||
flag := "quiet"
|
flag := "quiet"
|
||||||
rootCmd.PersistentFlags().BoolP(
|
rootCmd.PersistentFlags().BoolP(
|
||||||
flag, "q", false,
|
flag, "q", false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user