1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-15 07:58:15 +08:00

start adopting cmds3.0 - lots of errors!

- 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>
This commit is contained in:
keks
2017-11-20 15:11:10 +01:00
committed by Jeromy
parent 2140aa9578
commit bd9576fa57
71 changed files with 1281 additions and 530 deletions

27
core/commands/env.go Normal file
View File

@ -0,0 +1,27 @@
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()
}