diff --git a/core/commands/cmdenv/env.go b/core/commands/cmdenv/env.go index c3f36fd8c..603a8bd33 100644 --- a/core/commands/cmdenv/env.go +++ b/core/commands/cmdenv/env.go @@ -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 +}