Add -v flag to print version

This commit is contained in:
adnano 2021-04-12 00:31:55 -04:00
parent 1458f336b4
commit 413748e6e2
2 changed files with 14 additions and 4 deletions

View file

@ -26,8 +26,7 @@ doc: $(DOCS)
kiln: $(GOSRC) kiln: $(GOSRC)
$(GO) build $(GOFLAGS) \ $(GO) build $(GOFLAGS) \
-ldflags "-X main.Prefix=$(PREFIX) \ -ldflags "-X main.Version=$(VERSION)" \
-X main.Version=$(VERSION)" \
-o $@ -o $@
clean: clean:

11
main.go
View file

@ -11,16 +11,27 @@ import (
"strings" "strings"
) )
var (
Version string
)
func main() { func main() {
var ( var (
task string task string
config string config string
version bool
) )
flag.StringVar(&task, "t", "all", "the task to run") flag.StringVar(&task, "t", "all", "the task to run")
flag.StringVar(&config, "c", "config.toml", "the configuration file to use") flag.StringVar(&config, "c", "config.toml", "the configuration file to use")
flag.BoolVar(&version, "v", false, "print version")
flag.Parse() flag.Parse()
if version {
fmt.Println("kiln", Version)
return
}
// Load config // Load config
cfg, err := LoadConfig(config) cfg, err := LoadConfig(config)
if err != nil { if err != nil {