forked from MTSR/mapserver
dump config
This commit is contained in:
parent
0a13747950
commit
2eb0d3851a
@ -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
13
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 {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
type ParamsType struct {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user