-
Notifications
You must be signed in to change notification settings - Fork 1
/
shell.go
41 lines (32 loc) · 829 Bytes
/
shell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package commands
import (
"context"
"fmt"
"path"
"strconv"
cli "github.com/urfave/cli"
"github.com/ipsn/go-ipfs/gxlibs/github.com/ipfs/iptb/testbed"
)
var ShellCmd = cli.Command{
Category: "CORE",
Name: "shell",
Usage: "starts a shell within the context of node",
ArgsUsage: "<node>",
Action: func(c *cli.Context) error {
flagRoot := c.GlobalString("IPTB_ROOT")
flagTestbed := c.GlobalString("testbed")
if !c.Args().Present() {
return NewUsageError("shell takes exactly 1 argument")
}
i, err := strconv.Atoi(c.Args().First())
if err != nil {
return fmt.Errorf("parse err: %s", err)
}
tb := testbed.NewTestbed(path.Join(flagRoot, "testbeds", flagTestbed))
nodes, err := tb.Nodes()
if err != nil {
return err
}
return nodes[i].Shell(context.Background(), nodes)
},
}