提交 bf15999c 作者: Overbool

cmds/env: add a config path helper

License: MIT
Signed-off-by: 's avatarOverbool <overbool.xu@gmail.com>
上级 7ecbd211
......@@ -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
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论