Skip to content

Commit

Permalink
allow config file override
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmonsays committed Jan 24, 2016
1 parent 6832c81 commit f599616
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/runitcmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func main() {
}

app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "override configuration file",
},
cli.StringFlag{
Name: "level, l",
Value: "WARN",
Expand All @@ -47,10 +51,18 @@ func main() {
app.Before = func(c *cli.Context) error {
gologging.SetLogLevel(c.String("level"))

config_file := c.String("config")
config_files := []string{
"/etc/runitcmd.yaml",
filepath.Join(os.Getenv("HOME"), ".runitcmd.yaml"),
}

user_config := filepath.Join(os.Getenv("HOME"), ".runitcmd.yaml")
if config_file == "" {
config_files = append(config_files, user_config)
} else {
config_files = []string{config_file}
}

app.Conf = GetDefaultConfig()
for _, config_file := range config_files {
_, err := os.Stat(config_file)
Expand Down

0 comments on commit f599616

Please sign in to comment.