diff --git a/Makefile b/Makefile index 850246c..7b8f6d9 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ BIN_NAME = "hmdeploy" +BIN_INSTALL = $(shell whereis $(BIN_NAME) | cut -d ' ' -f2 | xargs rm -f) run: lint @go run main.go build: lint @echo "building binary..." - @go build -o $(BIN_NAME) main.go && echo "$(BIN_NAME) built" + @go build -ldflags "-X main.Version=0.1.0" -o $(BIN_NAME) main.go && echo "$(BIN_NAME) built" -install: - @$(shell whereis $(BIN_NAME) | cut -d ' ' -f2 | xargs rm -f) - @go install +install: build + @mv $(BIN_NAME) $(GOPATH)/bin/hmdeploy @echo "program installed: $(GOPATH)/bin/hmdeploy" lint: diff --git a/README.md b/README.md index 21e1e03..5acbcd7 100644 --- a/README.md +++ b/README.md @@ -124,10 +124,14 @@ Usage of hmdeploy: show debug logs -destroy delete the deployed project + -details + extract swarm details and return -no-nginx no Nginx deployment -path string define the .homeserver project root dir (default ".") + -version + extract swarm details and return # if your are in the project dir with a `.homeserver` # you can then launch the program directly diff --git a/main.go b/main.go index f2b190d..1eef239 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,8 @@ const ( MaxDeployers int = 2 ) +var Version string + var HOME_PATH = os.Getenv("HOME") var ( @@ -343,6 +345,7 @@ func main() { //nolint: funlen //TODO: to reduce noNginx := flag.Bool("no-nginx", false, "no Nginx deployment") debug := flag.Bool("debug", false, "show debug logs") details := flag.Bool("details", false, "extract swarm details and return") + version := flag.Bool("version", false, "extract swarm details and return") confirm := flag.Bool( "confirm", false, @@ -350,6 +353,11 @@ func main() { //nolint: funlen //TODO: to reduce ) flag.Parse() + if *version { + fmt.Println("hmdeploy version: v" + Version) + os.Exit(0) + } + initLogger(*debug) hmmap, err := loadHMMap()