diff --git a/Makefile b/Makefile index 3b3b630..d7aeb67 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,8 @@ GO_FILES=$(shell find $(ROOT_DIR) -name '*.go') # Gather list of expected binaries BINARIES=txtop -# Extract Go module name from go.mod -GOMODULE=$(shell grep ^module $(ROOT_DIR)/go.mod | awk '{ print $$2 }') - # Set version strings based on git tag and current ref -#GO_LDFLAGS=-ldflags "-s -w -X '$(GOMODULE)/internal/version.Version=$(shell git describe --tags --exact-match 2>/dev/null)' -X '$(GOMODULE)/internal/version.CommitHash=$(shell git rev-parse --short HEAD)'" -GO_LDFLAGS=-ldflags "-s -w" +GO_LDFLAGS=-ldflags "-s -w -X 'main.Version=$(shell git describe --tags --exact-match 2>/dev/null)' -X 'main.CommitHash=$(shell git rev-parse --short HEAD)'" .PHONY: build mod-tidy clean test diff --git a/main.go b/main.go index d3234f0..4f88fa9 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,18 @@ var text = tview.NewTextView(). var paused bool = false +// These are populated at build time +var Version string +var CommitHash string + +func GetVersionString() string { + if Version != "" { + return fmt.Sprintf("%s (commit %s)", Version, CommitHash) + } else { + return fmt.Sprintf("devel (commit %s)", CommitHash) + } +} + type Config struct { App AppConfig Node NodeConfig @@ -333,7 +345,7 @@ func main() { GetTransactions(oConn), )) } - headerText.SetText(fmt.Sprintln(" > txtop")) + headerText.SetText(fmt.Sprintln(" > txtop -", GetVersionString())) footerText.SetText( fmt.Sprintln(" [yellow](esc/q)[white] Quit | [yellow](p)[white] Pause"), )