-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathautodeploy.go
More file actions
64 lines (57 loc) · 1.9 KB
/
autodeploy.go
File metadata and controls
64 lines (57 loc) · 1.9 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
package parser
import (
"github.com/drycc/workflow-cli/internal/commands"
"github.com/drycc/workflow-cli/internal/completion"
"github.com/drycc/workflow-cli/pkg/i18n"
"github.com/spf13/cobra"
)
// NewAutodeployCommand creates the autodeploy command
func NewAutodeployCommand(cmdr *commands.DryccCmd) *cobra.Command {
cmd := &cobra.Command{
Use: "autodeploy",
Short: i18n.T("Manage autodeploy if or not for applications"),
RunE: func(_ *cobra.Command, _ []string) error {
return cmdr.AutodeployInfo(app)
},
}
cmd.PersistentFlags().StringVarP(&app, "app", "a", "", i18n.T("The uniquely identifiable name for the application"))
appCompletion := completion.AppCompletion{ArgsLen: -1, ConfigFile: &cmdr.ConfigFile}
cmd.RegisterFlagCompletionFunc("app", appCompletion.CompletionFunc)
cmd.AddCommand(autodeployInfo(cmdr))
cmd.AddCommand(autodeployEnable(cmdr))
cmd.AddCommand(autodeployDisable(cmdr))
return cmd
}
// AutodeployInfo Information about the autodeploy
func autodeployInfo(cmdr *commands.DryccCmd) *cobra.Command {
cmd := &cobra.Command{
Use: "info",
Short: i18n.T("Prints info about the current application's autodeploy if or not"),
RunE: func(_ *cobra.Command, _ []string) error {
return cmdr.AutodeployInfo(app)
},
}
return cmd
}
// AutodeployEnable creates the autodeploy enable command
func autodeployEnable(cmdr *commands.DryccCmd) *cobra.Command {
cmd := &cobra.Command{
Use: "enable",
Short: i18n.T("Enables autodeploy for an app"),
RunE: func(_ *cobra.Command, _ []string) error {
return cmdr.AutodeployEnable(app)
},
}
return cmd
}
// AutodeployDisable creates the autodeploy disable command
func autodeployDisable(cmdr *commands.DryccCmd) *cobra.Command {
cmd := &cobra.Command{
Use: "disable",
Short: i18n.T("Disables autodeploy for an app"),
RunE: func(_ *cobra.Command, _ []string) error {
return cmdr.AutodeployDisable(app)
},
}
return cmd
}