-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.go
60 lines (48 loc) · 1.42 KB
/
list.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"github.com/codegangsta/cli"
"os"
"os/exec"
"syscall"
)
var List = cli.Command{
Name: "list",
ShortName: "l",
Usage: "Display currently running or existing vms",
Description: "Shows detail about currently running or existing vms",
Subcommands: []cli.Command{
{
Name: "available",
Usage: "Shows available vms",
Action: func(c *cli.Context) {
binary, err := exec.LookPath("VBoxManage")
if err != nil {
panic(err)
}
args := []string{"VBoxManage", "list", "vms"}
env := os.Environ()
err = syscall.Exec(binary, args, env)
if err != nil {
panic(err)
}
},
},
{
Name: "running",
Usage: "Shows currently running vms",
Action: func(c *cli.Context) {
binary, err := exec.LookPath("VBoxManage")
if err != nil {
panic(err)
}
args := []string{"VBoxManage", "list", "runningvms"}
env := os.Environ()
err = syscall.Exec(binary, args, env)
if err != nil {
panic(err)
}
},
},
},
Action: cli.ShowSubcommandHelp,
}