1
0
forked from MTSR/mapserver

version info

This commit is contained in:
Thomas Rudin 2019-01-07 08:56:02 +01:00
parent 38787bcca2
commit d916f0e03c
3 changed files with 22 additions and 5 deletions

View File

@ -1,6 +1,9 @@
VERSION=2.0
LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION}"
test: test:
go test ./... go test ./...
build: build:
go build . go build ${LDFLAGS}

16
main.go
View File

@ -3,12 +3,28 @@ package main
import ( import (
"mapserver/params" "mapserver/params"
"mapserver/worldconfig" "mapserver/worldconfig"
"flag"
"fmt" "fmt"
) )
var (
Version string
)
func main() { func main() {
p := params.Parse() p := params.Parse()
if p.Help { if p.Help {
flag.PrintDefaults()
return
}
if p.Version {
fmt.Print("Mapserver version: ")
if Version == "" {
Version = "SNAPSHOT"
}
fmt.Println(Version)
return return
} }

View File

@ -8,6 +8,7 @@ type ParamsType struct {
Worlddir string Worlddir string
Port int Port int
Help bool Help bool
Version bool
} }
func Parse() ParamsType { func Parse() ParamsType {
@ -16,11 +17,8 @@ func Parse() ParamsType {
flag.StringVar(&(params.Worlddir), "worlddir", "./", "world directory") flag.StringVar(&(params.Worlddir), "worlddir", "./", "world directory")
flag.IntVar(&(params.Port), "port", 8080, "port to use") flag.IntVar(&(params.Port), "port", 8080, "port to use")
flag.BoolVar(&(params.Help), "help", false, "Show help") flag.BoolVar(&(params.Help), "help", false, "Show help")
flag.BoolVar(&(params.Version), "version", false, "Show version")
flag.Parse() flag.Parse()
if params.Help {
flag.PrintDefaults()
}
return params return params
} }