1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-19 12:42:23 +08:00
Files
Michael Muré d716a93fae ipfs files stat: use go-ipfs-cmds
License: MIT
Signed-off-by: Michael Muré <batolettre@gmail.com>
2018-02-04 01:51:37 +01:00

30 lines
668 B
Go

package commands
import (
"fmt"
"github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/repo/config"
)
// GetNode extracts the node from the environment.
func GetNode(env interface{}) (*core.IpfsNode, error) {
ctx, ok := env.(*commands.Context)
if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
}
return ctx.GetNode()
}
// GetConfig extracts the config from the environment.
func GetConfig(env interface{}) (*config.Config, error) {
ctx, ok := env.(*commands.Context)
if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
}
return ctx.GetConfig()
}