Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5e647ba

Browse files
authored
chore: improve workspace proxy create cli flow (#7907)
* chore: improve workspace proxy create cli flow
1 parent26f575e commit5e647ba

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

‎enterprise/cli/workspaceproxy.go

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
208208
proxyNamestring
209209
displayNamestring
210210
proxyIconstring
211+
noPromptsbool
211212
formatter=newUpdateProxyResponseFormatter()
212213
)
213214

@@ -221,8 +222,43 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
221222
),
222223
Handler:func(inv*clibase.Invocation)error {
223224
ctx:=inv.Context()
225+
varerrerror
226+
ifproxyName==""&&!noPrompts {
227+
proxyName,err=cliui.Prompt(inv, cliui.PromptOptions{
228+
Text:"Proxy Name:",
229+
})
230+
iferr!=nil {
231+
returnerr
232+
}
233+
}
234+
ifdisplayName==""&&!noPrompts {
235+
displayName,err=cliui.Prompt(inv, cliui.PromptOptions{
236+
Text:"Display Name:",
237+
Default:proxyName,
238+
})
239+
iferr!=nil {
240+
returnerr
241+
}
242+
}
243+
244+
ifproxyIcon==""&&!noPrompts {
245+
proxyIcon,err=cliui.Prompt(inv, cliui.PromptOptions{
246+
Text:"Icon URL:",
247+
Default:"/emojis/1f5fa.png",
248+
Validate:func(sstring)error {
249+
if!(strings.HasPrefix(s,"/emojis/")||strings.HasPrefix(s,"http")) {
250+
returnxerrors.New("icon must be a relative path to an emoji or a publicly hosted image URL")
251+
}
252+
returnnil
253+
},
254+
})
255+
iferr!=nil {
256+
returnerr
257+
}
258+
}
259+
224260
ifproxyName=="" {
225-
returnxerrors.Errorf("proxy name is required")
261+
returnxerrors.New("proxy name is required")
226262
}
227263

228264
resp,err:=client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{
@@ -260,6 +296,11 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
260296
Description:"Display icon of the proxy.",
261297
Value:clibase.StringOf(&proxyIcon),
262298
},
299+
clibase.Option{
300+
Flag:"no-prompt",
301+
Description:"Disable all input prompting, and fail if any required flags are missing.",
302+
Value:clibase.BoolOf(&noPrompts),
303+
},
263304
)
264305
returncmd
265306
}
@@ -355,8 +396,11 @@ func newUpdateProxyResponseFormatter() *updateProxyResponseFormatter {
355396
if!ok {
356397
returnnil,xerrors.Errorf("unexpected type %T",data)
357398
}
358-
returnfmt.Sprintf("Workspace Proxy %q created successfully. Save this token, it will not be shown again."+
359-
"\nToken: %s",response.Proxy.Name,response.ProxyToken),nil
399+
400+
returnfmt.Sprintf("Workspace Proxy %q updated successfully.\n"+
401+
cliui.DefaultStyles.Placeholder.Render("—————————————————————————————————————————————————")+"\n"+
402+
"Save this authentication token, it will not be shown again.\n"+
403+
"Token: %s\n",response.Proxy.Name,response.ProxyToken),nil
360404
}),
361405
cliui.JSONFormat(),
362406
// Table formatter expects a slice, make a slice of one.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp