From 2eb0d3851ac890765b2935cbe5ee640af5815e04 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 18 Jan 2019 09:11:13 +0100 Subject: [PATCH] dump config --- app/config.go | 2 ++ main.go | 13 ++++++++++++- params/params.go | 6 ++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/config.go b/app/config.go index 6caf74a..0dbd5fc 100644 --- a/app/config.go +++ b/app/config.go @@ -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) diff --git a/main.go b/main.go index a6f11ee..6556b67 100644 --- a/main.go +++ b/main.go @@ -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 { diff --git a/params/params.go b/params/params.go index 29affe0..74c4cdc 100644 --- a/params/params.go +++ b/params/params.go @@ -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