mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 04:47:45 +08:00
Merge pull request #5712 from overbool/feat/cmds/add-config-helper
cmds/env: add a config path helper
This commit is contained in:
commit
8736202417
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user