Skip to content

Commit

Permalink
Add --version flag (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Mar 9, 2024
1 parent 1e6de25 commit 87f8c5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ all: fmt lint vet build
.PHONY: build
build: $(BIN) ; $(info $(M) building executable…) @ ## Build program binary
$Q CGO_ENABLED=0 $(GO) build \
-ldflags "-X main.gitVersion=$$(git describe --tags) -X \"main.buildTime=$$(date -u '+%Y-%m-%d %H:%M:%S %Z')\"" \
-ldflags "-X main.gitVersion=$$(git describe --tags) -X $(MODULE)/cmd.gitVersion=$$(git describe --tags) -X \"main.buildTime=$$(date -u '+%Y-%m-%d %H:%M:%S %Z')\" -X \"$(MODULE)/cmd.buildTime=$$(date -u '+%Y-%m-%d %H:%M:%S %Z')\"" \
-tags release \
-o $(BIN)/$(notdir $(basename $(MODULE)))$(binext)
# Tools
Expand Down
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ import (
)

var cfgFile string
var (
gitVersion string
buildTime string
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "chia-exporter",
Short: "Prometheus metric exporter for Chia Blockchain",
Version: fmt.Sprintf("%s (%s)", gitVersion, buildTime),
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down

0 comments on commit 87f8c5f

Please sign in to comment.