Skip to content

Commit

Permalink
cmds/env: add a config path helper
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
  • Loading branch information
overbool committed Nov 2, 2018
1 parent 7ecbd21 commit 33019df
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()
}

// GetConfigPath extracts the config path 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 33019df

Please sign in to comment.