-
Notifications
You must be signed in to change notification settings - Fork 5
/
cmd.go
48 lines (45 loc) · 1.73 KB
/
cmd.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
package main
type cmdInfo struct {
children map[string]*cmdInfo
cb func(*runInfo) error
flags []cmdFlag
}
type cmdFlag struct {
Name string // name as on command line
Usage string
Required bool // if true, value is required
}
var rootCmd = &cmdInfo{
children: map[string]*cmdInfo{
"version": {cb: showVersion},
"shells": {
children: map[string]*cmdInfo{
"ls": {cb: shellsList},
"info": {cb: shellsInfo, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to fetch", Required: true}}},
"state": {cb: shellsState, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to fetch status of", Required: true}}},
"start": {cb: shellsStart, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to start", Required: true}}},
"stop": {cb: shellsStop, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to stop", Required: true}}},
"view": {cb: shellsView, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to get view URL", Required: true}}},
"restart": {cb: shellsRestart, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to start", Required: true}}},
"reboot": {cb: shellsReboot, flags: []cmdFlag{{Name: "shell", Usage: "Specify shell to stop", Required: true}}},
},
},
"os": {
children: map[string]*cmdInfo{
"image": {
children: map[string]*cmdInfo{
"ls": {cb: osImgList, flags: []cmdFlag{{Name: "os", Usage: "Specify the OS to list images", Required: true}}},
"upload": {
cb: osImgUpload,
flags: []cmdFlag{
{Name: "os", Usage: "Specify the OS to upload to", Required: true},
{Name: "file", Usage: "File to be uploaded", Required: true},
},
},
},
},
"ls": {cb: osList},
},
},
},
}