From 413748e6e229c21bdd8f8eed94ba5307a21addb8 Mon Sep 17 00:00:00 2001 From: adnano Date: Mon, 12 Apr 2021 00:31:55 -0400 Subject: [PATCH] Add -v flag to print version --- Makefile | 3 +-- main.go | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 238e19b..8c1bc9c 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,7 @@ doc: $(DOCS) kiln: $(GOSRC) $(GO) build $(GOFLAGS) \ - -ldflags "-X main.Prefix=$(PREFIX) \ - -X main.Version=$(VERSION)" \ + -ldflags "-X main.Version=$(VERSION)" \ -o $@ clean: diff --git a/main.go b/main.go index 2b2be39..857b153 100644 --- a/main.go +++ b/main.go @@ -11,16 +11,27 @@ import ( "strings" ) +var ( + Version string +) + func main() { var ( - task string - config string + task string + config string + version bool ) flag.StringVar(&task, "t", "all", "the task to run") flag.StringVar(&config, "c", "config.toml", "the configuration file to use") + flag.BoolVar(&version, "v", false, "print version") flag.Parse() + if version { + fmt.Println("kiln", Version) + return + } + // Load config cfg, err := LoadConfig(config) if err != nil {