Skip to content

Commit

Permalink
add: version cli
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Jan 26, 2025
1 parent 3889000 commit f60208b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ release:
release --clean --skip validate

build:
go build -o ./build/price-feeder
go build -ldflags "-X github.com/ExocoreNetwork/price-feeder/version.Version=$(shell git describe --tags)" -o ./build/price-feeder

.PHONY: build
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ func init() {
rootCmd.AddCommand(
startCmd,
debugStartCmd,
versionCmd,
)
}
21 changes: 21 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"fmt"

"github.com/ExocoreNetwork/price-feeder/version"
"github.com/spf13/cobra"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "display version information",
Long: "display version information",
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
// do nothing here, just override persistentPreRunE defined in parent
return nil
},
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
},
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

var Name, Version, Commit string
var Version string

0 comments on commit f60208b

Please sign in to comment.