File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ builds:
2121 ldflags :
2222 - " -s"
2323 - " -w"
24- # - "-X github.com/snyk/parlay/internal/commands.version={{.Version}}"
24+ - " -X github.com/snyk/parlay/internal/commands.version={{.Version}}"
2525
2626archives :
2727- format : tar.gz
Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ import (
1313 "github.com/snyk/parlay/internal/commands/snyk"
1414)
1515
16+ // These values are set at build time
17+ var (
18+ version = ""
19+ )
20+
1621func NewDefaultCommand () * cobra.Command {
1722 output := zerolog.ConsoleWriter {Out : os .Stderr }
1823 logger := zerolog .New (output ).With ().Timestamp ().Logger ()
@@ -21,6 +26,7 @@ func NewDefaultCommand() *cobra.Command {
2126 Use : "parlay" ,
2227 Short : "Enrich an SBOM with context from third party services" ,
2328 SilenceUsage : true ,
29+ Version : GetVersion (),
2430 DisableFlagsInUseLine : true ,
2531 Run : func (cmd * cobra.Command , args []string ) {
2632 if err := cmd .Help (); err != nil {
@@ -40,10 +46,16 @@ func NewDefaultCommand() *cobra.Command {
4046 cmd .PersistentFlags ().Bool ("debug" , false , "" )
4147 viper .BindPFlag ("debug" , cmd .PersistentFlags ().Lookup ("debug" )) //nolint:errcheck
4248
49+ cmd .SetVersionTemplate (`{{.Version}}` )
50+
4351 cmd .AddCommand (ecosystems .NewEcosystemsRootCommand (logger ))
4452 cmd .AddCommand (snyk .NewSnykRootCommand (logger ))
4553 cmd .AddCommand (deps .NewDepsRootCommand (logger ))
4654 cmd .AddCommand (scorecard .NewRootCommand (logger ))
4755
4856 return & cmd
4957}
58+
59+ func GetVersion () string {
60+ return version
61+ }
You can’t perform that action at this time.
0 commit comments