-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathshortcuts.go
More file actions
87 lines (69 loc) · 2.3 KB
/
shortcuts.go
File metadata and controls
87 lines (69 loc) · 2.3 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package parser
import (
"github.com/drycc/workflow-cli/internal/commands"
"github.com/drycc/workflow-cli/internal/template"
"github.com/drycc/workflow-cli/pkg/i18n"
"github.com/spf13/cobra"
)
type Shortcuts interface {
Create(cmdr *commands.DryccCmd) []*cobra.Command
}
var SupportedShortcuts = []Shortcuts{
&AuthShortcuts{}, &AppsShortcuts{}, &PsShortcuts{}, &BuildsShortcuts{}, &PtsShortcuts{},
}
type AuthShortcuts struct{}
func (a *AuthShortcuts) Create(cmdr *commands.DryccCmd) []*cobra.Command {
login := authLogin(cmdr)
login.Example = "drycc login http://drycc.local3.dryccapp.com/"
logout := authLogout(cmdr)
logout.Example = "drycc auth logout"
whoami := authWhoami(cmdr)
whoami.Example = "drycc whoami"
return []*cobra.Command{login, logout, whoami}
}
type AppsShortcuts struct{}
func (a *AppsShortcuts) Create(cmdr *commands.DryccCmd) []*cobra.Command {
destroy := appsDestroy(cmdr)
destroy.Example = "drycc destroy -a <app> --confirm <app>"
run := appsRun(cmdr)
run.Example = template.CustomExample(
"drycc run --mount=myvolume:/data -- 'echo hello'",
map[string]string{
"<volume>": i18n.T("The volume name"),
"<path>": i18n.T("The filesystem path"),
"<command>": i18n.T("The shell command to run inside the container"),
},
)
return []*cobra.Command{appsCreate(cmdr), destroy, appsInfo(cmdr), appsOpen(cmdr), run}
}
type PsShortcuts struct{}
func (p *PsShortcuts) Create(cmdr *commands.DryccCmd) []*cobra.Command {
exec := psExecCommand(cmdr)
exec.Example = template.CustomExample(
"drycc exec my-pod -it -- bash",
map[string]string{
"<pod>": i18n.T("The pod name for the application"),
},
)
logs := psLogsCommand(cmdr)
logs.Example = "drycc logs my-pod"
return []*cobra.Command{exec, logs}
}
type BuildsShortcuts struct{}
func (b *BuildsShortcuts) Create(cmdr *commands.DryccCmd) []*cobra.Command {
create := buildsCreate(cmdr)
create.Use = `pull <image>`
return []*cobra.Command{create}
}
type PtsShortcuts struct{}
func (p *PtsShortcuts) Create(cmdr *commands.DryccCmd) []*cobra.Command {
scale := ptsScaleCommand(cmdr)
scale.Example = template.CustomExample(
"drycc scale web=3",
map[string]string{
"<ptype>": i18n.T("The process name as defined in your Procfile"),
"<num>": i18n.T("The number of processes"),
},
)
return []*cobra.Command{scale}
}