Commit ed108634 authored by Benoit Benedetti's avatar Benoit Benedetti

Configuration as command line arg #222

parent 4e1717db
......@@ -124,7 +124,7 @@ func isLocalhost(s string) bool {
// loadConfigs loads configuration from a file or stdin (piped).
// The configurations are grouped by bind address.
// Configuration is obtained from one of three sources, tried
// in this order: 1. -conf flag, 2. stdin, 3. Caddyfile.
// in this order: 1. -conf flag, 2. stdin, 4. command line argument 3. Caddyfile.
// If none of those are available, a default configuration is
// loaded.
func loadConfigs() (config.Group, error) {
......@@ -155,6 +155,12 @@ func loadConfigs() (config.Group, error) {
}
}
// Command line Arg
if flag.NArg() > 0 {
confBody := ":" + config.DefaultPort + "\n" + strings.Join(flag.Args(), "\n")
return config.Load("args", bytes.NewBufferString(confBody))
}
// Caddyfile
file, err := os.Open(config.DefaultConfigFile)
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment