mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
Add -v flag to print version
This commit is contained in:
parent
1458f336b4
commit
413748e6e2
3
Makefile
3
Makefile
|
@ -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
11
main.go
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue