Add -v flag to print version

This commit is contained in:
Adnan Maolood 2021-04-12 00:31:55 -04:00
parent 1389d339ca
commit 580cc88e8a
2 changed files with 14 additions and 4 deletions

View file

@ -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:

15
main.go
View file

@ -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 {