mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-25 20:37:53 +08:00
- move go-ipfs-cmds/legacy to go-ipfs/commands/legacy - update cmds,cmdkit; go test ./... ok License: MIT Signed-off-by: keks <keks@cryptoscope.co>
28 lines
562 B
Go
28 lines
562 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"
|
|
)
|
|
|
|
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()
|
|
}
|
|
|
|
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()
|
|
}
|