Skip to content

Commit

Permalink
Add --config support
Browse files Browse the repository at this point in the history
This adds the ability to use --config. It's a little strange though
because you have to set it before the subcommand. Not a huge fan of this
format.
  • Loading branch information
michaeljs1990 committed Feb 18, 2019
1 parent e0b29ea commit d33af8a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmds/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ func (u UniqueOrderedSet) Add(s string) UniqueOrderedSet {
}

func getCollinsClient(c *cli.Context) *collins.Client {
// We just set the COLLINS_CLIENT_CONFIG so we can use the NewClientFromYaml
// helper function still which will still run through all the default config paths.
if c.GlobalIsSet("config") {
os.Setenv("COLLINS_CLIENT_CONFIG", c.GlobalString("config"))
}

collins, err := collins.NewClientFromYaml()
if err != nil {
fmt.Println("You can use COLLINS_CLIENT_CONFIG env to set the location of your config")
fmt.Println("You can use COLLINS_CLIENT_CONFIG env or --config to set the location of your config")
logAndDie(err.Error())
}

return collins
}

Expand Down

0 comments on commit d33af8a

Please sign in to comment.