1
0
forked from MTSR/mapserver

dump config

This commit is contained in:
NatureFreshMilk 2019-01-18 09:11:13 +01:00
parent 0a13747950
commit 2eb0d3851a
3 changed files with 18 additions and 3 deletions

View File

@ -8,11 +8,13 @@ import (
type Config struct {
Port int `json:"port"`
EnableInitialRendering bool `json:"enableinitialrendering"`
}
func ParseConfig(filename string) (*Config, error) {
cfg := Config{
Port: 80,
EnableInitialRendering: true,
}
info, err := os.Stat(filename)

13
main.go
View File

@ -6,6 +6,8 @@ import (
"mapserver/layerconfig"
"mapserver/app"
"mapserver/params"
"encoding/json"
"fmt"
)
@ -35,8 +37,17 @@ func main() {
panic(err)
}
//setup app context
if p.Dumpconfig {
str, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(str))
return
}
//setup app context
ctx, err := app.Setup(p, cfg)
if err != nil {

View File

@ -5,8 +5,9 @@ import (
)
type ParamsType struct {
Help bool
Version bool
Help bool
Version bool
Dumpconfig bool
}
func Parse() ParamsType {
@ -14,6 +15,7 @@ func Parse() ParamsType {
flag.BoolVar(&(params.Help), "help", false, "Show help")
flag.BoolVar(&(params.Version), "version", false, "Show version")
flag.BoolVar(&(params.Dumpconfig), "dumpconfig", false, "dump mapserver.json and exit")
flag.Parse()
return params