-
Notifications
You must be signed in to change notification settings - Fork 13
/
export.go
202 lines (174 loc) · 5.47 KB
/
export.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package cmdtree
import (
"strings"
"github.com/ActiveState/cli/internal/captain"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runners/export"
"github.com/ActiveState/cli/internal/runners/export/config"
"github.com/ActiveState/cli/internal/runners/export/docs"
"github.com/ActiveState/cli/internal/runners/export/ghactions"
)
func newExportCommand(prime *primer.Values) *captain.Command {
runner := export.NewExport()
return captain.NewCommand(
"export",
locale.Tl("export_title", "Exporting Information"),
locale.T("export_cmd_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, args []string) error {
return runner.Run(ccmd)
}).SetGroup(UtilsGroup).SetSupportsStructuredOutput()
}
func newJWTCommand(prime *primer.Values) *captain.Command {
jwt := export.NewJWT(prime)
params := export.JWTParams{}
return captain.NewCommand(
"jwt",
locale.Tl("export_jwt_title", "Exporting Credentials"),
locale.T("export_jwt_cmd_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, args []string) error {
return jwt.Run(¶ms)
}).SetSupportsStructuredOutput()
}
func newPrivateKeyCommand(prime *primer.Values) *captain.Command {
privateKey := export.NewPrivateKey(prime)
params := export.PrivateKeyParams{}
return captain.NewCommand(
"private-key",
locale.Tl("export_privkey_title", "Exporting Private Key"),
locale.T("export_privkey_cmd_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, args []string) error {
return privateKey.Run(¶ms)
}).SetSupportsStructuredOutput()
}
func newAPIKeyCommand(prime *primer.Values) *captain.Command {
apikey := export.NewAPIKey(prime)
params := export.APIKeyRunParams{}
return captain.NewCommand(
"new-api-key",
locale.Tl("export_new_api_key_title", "Exporting New API Key"),
locale.T("export_new_api_key_cmd_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{
{
Name: locale.T("export_new_api_key_arg_name"),
Description: locale.T("export_new_api_key_arg_name_description"),
Value: ¶ms.Name,
Required: true,
},
},
func(ccmd *captain.Command, args []string) error {
params.IsAuthed = prime.Auth().Authenticated
return apikey.Run(params)
}).SetSupportsStructuredOutput()
}
func newExportConfigCommand(prime *primer.Values) *captain.Command {
runner := config.New(prime)
params := config.ConfigParams{}
return captain.NewCommand(
"config",
locale.Tl("export_config_title", "Exporting Configuration Data"),
locale.T("export_config_cmd_description"),
prime,
[]*captain.Flag{
{
Name: "filter",
Description: locale.Tr(
"export_config_flag_filter_description",
strings.Join(config.SupportedFilters(), ", "),
),
Value: ¶ms.Filter,
},
},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
return runner.Run(ccmd, ¶ms)
}).SetSupportsStructuredOutput().SetUnstable(true)
}
func newExportGithubActionCommand(prime *primer.Values) *captain.Command {
runner := ghactions.New(prime)
params := ghactions.Params{}
return captain.NewCommand(
"github-actions",
locale.Tl("export_ghactions_title", "Exporting Github Action Workflow"),
locale.Tl("export_ghactions_description", "Create a github action workflow for your project"),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
return runner.Run(¶ms)
}).SetUnstable(true)
}
func newExportDocsCommand(prime *primer.Values) *captain.Command {
runner := docs.New(prime)
params := docs.Params{}
cmd := captain.NewCommand(
"_docs",
locale.Tl("export_docs_title", "Export state tool command reference in markdown format"),
locale.Tl("export_docs_description", ""),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
return runner.Run(¶ms, ccmd)
})
cmd.SetHidden(true)
return cmd
}
func newExportEnvCommand(prime *primer.Values) *captain.Command {
runner := export.NewEnv(prime)
cmd := captain.NewCommand(
"env",
locale.Tl("env_docs_title", "Exporting environment"),
locale.Tl("env_docs_description", "Export the environment variables associated with your runtime."),
prime,
[]*captain.Flag{},
[]*captain.Argument{},
func(ccmd *captain.Command, _ []string) error {
return runner.Run()
})
cmd.SetSupportsStructuredOutput()
cmd.SetUnstable(true)
return cmd
}
func newLogCommand(prime *primer.Values) *captain.Command {
runner := export.NewLog(prime)
params := &export.LogParams{}
cmd := captain.NewCommand(
"log",
locale.Tl("export_log_title", "Show Log File"),
locale.Tl("export_log_description", "Show the path to a State Tool log file"),
prime,
[]*captain.Flag{
{
Name: "index",
Shorthand: "i",
Description: locale.Tl("flag_export_log_index", "The 0-based index of the log file to show, starting with the newest"),
Value: ¶ms.Index,
},
},
[]*captain.Argument{
{
Name: "prefix",
Description: locale.Tl("arg_export_log_prefix", "The prefix of the log file to show (e.g. state or state-svc). The default is 'state'"),
Required: false,
Value: ¶ms.Prefix,
},
},
func(ccmd *captain.Command, _ []string) error {
return runner.Run(params)
})
cmd.SetSupportsStructuredOutput()
cmd.SetUnstable(true)
return cmd
}