Skip to content

Commit

Permalink
print version
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Milde committed Dec 29, 2020
1 parent dfa2807 commit 2a94d6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
VERSION := $(shell git describe --tags)

run:
go run .

build:
@echo "Version: " $(VERSION)
-mkdir build
cd build; GOOS=linux GOARCH=arm go build -o gdu-linux-arm ..; tar czf gdu-linux-arm.tgz gdu-linux-arm
cd build; GOOS=linux GOARCH=amd64 go build -o gdu-linux-amd64 ..; tar czf gdu-linux-amd64.tgz gdu-linux-amd64
cd build; GOOS=windows GOARCH=amd64 go build -o gdu-windows-amd64.exe ..; zip gdu-windows-amd64.zip gdu-windows-amd64.exe
cd build; GOOS=darwin GOARCH=amd64 go build -o gdu-darwin-amd64 ..; tar czf gdu-darwin-amd64.tgz gdu-darwin-amd64
cd build; GOOS=linux GOARCH=arm go build -ldflags="-s -w -X 'main.AppVersion=$(VERSION)'" -o gdu-linux-arm ..; tar czf gdu-linux-arm.tgz gdu-linux-arm
cd build; GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X 'main.AppVersion=$(VERSION)'" -o gdu-linux-amd64 ..; tar czf gdu-linux-amd64.tgz gdu-linux-amd64
cd build; GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X 'main.AppVersion=$(VERSION)'" -o gdu-windows-amd64.exe ..; zip gdu-windows-amd64.zip gdu-windows-amd64.exe
cd build; GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X 'main.AppVersion=$(VERSION)'" -o gdu-darwin-amd64 ..; tar czf gdu-darwin-amd64.tgz gdu-darwin-amd64

test:
go test -v
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@ package main

import (
"flag"
"fmt"
"log"
"os"
"runtime"

"github.com/gdamore/tcell/v2"
)

// AppVersion stores the current version of the app
var AppVersion = "development"

func main() {
logFile := flag.String("log-file", "/dev/null", "Path to a logfile")
showVersion := flag.Bool("v", false, "Prints version")
flag.Parse()

if *showVersion {
fmt.Println("Version:\t", AppVersion)
return
}

f, err := os.OpenFile(*logFile, os.O_RDWR|os.O_CREATE, 0644)
if err != nil {
log.Fatalf("error opening file: %v", err)
Expand Down

0 comments on commit 2a94d6e

Please sign in to comment.