diff options
| author | horus_arch | 2015-07-27 22:24:09 +0200 |
|---|---|---|
| committer | horus_arch | 2015-07-27 22:52:09 +0200 |
| commit | ebfb0155ac6a4fba93ebb846878ca211e9384226 (patch) | |
| tree | 0f9faa9e9afed9ce92dbd8e5cac796a833f86cd5 /main.go | |
| download | ngxconf-ebfb0155ac6a4fba93ebb846878ca211e9384226.tar.gz | |
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -0,0 +1,35 @@ +package main + +import ( + "flag" + "log" + "os" + "text/template" +) + +//go:generate go run generate/include.go + +func main() { + conf_f := flag.String("config", "config.json", "Path to the configuration file.") + genConf_f := flag.Bool("genconfig", false, "Generate new configuration file and exit.") + flag.Parse() + + if *genConf_f { + GenConfig(*conf_f) + return + } + + Conf = NewConfiguration(*conf_f) + var err error + + if isGenerated() { + tmpl := template.Must(template.New("ngxconf").Parse(getTemplate())) + err = tmpl.Execute(os.Stdout, Conf) + } else { + tmpl := template.Must(template.New("ngxconf").ParseGlob(Conf.TemplateDir + "/*.tmpl")) + err = tmpl.ExecuteTemplate(os.Stdout, "server.tmpl", Conf) + } + if err != nil { + log.Fatal(err) + } +} |
