-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgaol.go
55 lines (46 loc) · 1.49 KB
/
gaol.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
package main
import (
"fmt"
"os"
"github.com/jessevdk/go-flags"
"github.com/contraband/gaol/commands"
)
type command struct {
name string
description string
command interface{}
}
func main() {
parser := flags.NewParser(&commands.Globals, flags.HelpFlag|flags.PassDoubleDash)
commands := []command{
{"ping", "check to see if the garden host is up", &commands.Ping{}},
{"create", "create a container", &commands.Create{}},
{"destroy", "destroy a container", &commands.Destroy{}},
{"list", "list running containers", &commands.List{}},
{"run", "run a command in the container", &commands.Run{}},
{"attach", "attach to a commmand running inside the container", &commands.Attach{}},
{"shell", "open a shell in the container", &commands.Shell{}},
{"stream-in", "stream data into the container", &commands.StreamIn{}},
{"stream-out", "stream data out of the container", &commands.StreamOut{}},
{"net-in", "map a port on the host to a port in the container", &commands.NetIn{}},
{"net-out", "whitelist an IP and port range for a container", &commands.NetOut{}},
{"properties", "list properties for a container", &commands.Properties{}},
{"set-gracetime", "set the grace time for a container", &commands.SetGraceTime{}},
}
for _, command := range commands {
_, err := parser.AddCommand(
command.name,
command.description,
"",
command.command,
)
if err != nil {
panic(err)
}
}
_, err := parser.Parse()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}