Skip to content

Commit

Permalink
Merge pull request #49 from blinklabs-io/feat/version
Browse files Browse the repository at this point in the history
feat: display version
  • Loading branch information
wolf31o2 authored Dec 27, 2023
2 parents c5c41c8 + 018bb6c commit 9a8d71e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
)
Expand Down

0 comments on commit 9a8d71e

Please sign in to comment.