@@ -208,6 +208,7 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
208208proxyName string
209209displayName string
210210proxyIcon string
211+ noPrompts bool
211212formatter = newUpdateProxyResponseFormatter ()
212213)
213214
@@ -221,8 +222,43 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
221222),
222223Handler :func (inv * clibase.Invocation )error {
223224ctx := inv .Context ()
225+ var err error
226+ if proxyName == "" && ! noPrompts {
227+ proxyName ,err = cliui .Prompt (inv , cliui.PromptOptions {
228+ Text :"Proxy Name:" ,
229+ })
230+ if err != nil {
231+ return err
232+ }
233+ }
234+ if displayName == "" && ! noPrompts {
235+ displayName ,err = cliui .Prompt (inv , cliui.PromptOptions {
236+ Text :"Display Name:" ,
237+ Default :proxyName ,
238+ })
239+ if err != nil {
240+ return err
241+ }
242+ }
243+
244+ if proxyIcon == "" && ! noPrompts {
245+ proxyIcon ,err = cliui .Prompt (inv , cliui.PromptOptions {
246+ Text :"Icon URL:" ,
247+ Default :"/emojis/1f5fa.png" ,
248+ Validate :func (s string )error {
249+ if ! (strings .HasPrefix (s ,"/emojis/" )|| strings .HasPrefix (s ,"http" )) {
250+ return xerrors .New ("icon must be a relative path to an emoji or a publicly hosted image URL" )
251+ }
252+ return nil
253+ },
254+ })
255+ if err != nil {
256+ return err
257+ }
258+ }
259+
224260if proxyName == "" {
225- return xerrors .Errorf ("proxy name is required" )
261+ return xerrors .New ("proxy name is required" )
226262}
227263
228264resp ,err := client .CreateWorkspaceProxy (ctx , codersdk.CreateWorkspaceProxyRequest {
@@ -260,6 +296,11 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
260296Description :"Display icon of the proxy." ,
261297Value :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)
264305return cmd
265306}
@@ -355,8 +396,11 @@ func newUpdateProxyResponseFormatter() *updateProxyResponseFormatter {
355396if ! ok {
356397return nil ,xerrors .Errorf ("unexpected type %T" ,data )
357398}
358- return fmt .Sprintf ("Workspace Proxy %q created successfully. Save this token, it will not be shown again." +
359- "\n Token: %s" ,response .Proxy .Name ,response .ProxyToken ),nil
399+
400+ return fmt .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}),
361405cliui .JSONFormat (),
362406// Table formatter expects a slice, make a slice of one.