Skip to content

Commit

Permalink
Merge pull request #5712 from overbool/feat/cmds/add-config-helper
Browse files Browse the repository at this point in the history
cmds/env: add a config path helper
  • Loading branch information
Stebalien authored Nov 2, 2018
2 parents 1c46381 + bf15999 commit 8736202
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/commands/cmdenv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ func GetConfig(env cmds.Environment) (*config.Config, error) {

return ctx.GetConfig()
}

// GetConfigRoot extracts the config root from the environment
func GetConfigRoot(env cmds.Environment) (string, error) {
ctx, ok := env.(*commands.Context)
if !ok {
return "", fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
}

return ctx.ConfigRoot, nil
}

0 comments on commit 8736202

Please sign in to comment.