Skip to content

chore: touch ups to wsproxy UX #8350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 7, 2023
Merged
Prev Previous commit
Next Next commit
chore: add confirm delete to workspace proxy delete cli
  • Loading branch information
Emyrk committed Jul 6, 2023
commit 7a073e8ac0f671df3252d77b0d980980a92a9a25
21 changes: 20 additions & 1 deletion enterprise/cli/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,32 @@ func (r *RootCmd) deleteProxy() *clibase.Cmd {
cmd := &clibase.Cmd{
Use: "delete <name|id>",
Short: "Delete a workspace proxy",
Options: clibase.OptionSet{
cliui.SkipPromptOption(),
},
Middleware: clibase.Chain(
clibase.RequireNArgs(1),
r.InitClient(client),
),
Handler: func(inv *clibase.Invocation) error {
ctx := inv.Context()
err := client.DeleteWorkspaceProxyByName(ctx, inv.Args[0])

wsproxy, err := client.WorkspaceProxyByName(ctx, inv.Args[0])
if err != nil {
return xerrors.Errorf("fetch workspace proxy %q: %w", inv.Args[0], err)
}

// Confirm deletion of the template.
_, err = cliui.Prompt(inv, cliui.PromptOptions{
Text: fmt.Sprintf("Delete this workspace proxy: %s?", cliui.DefaultStyles.Code.Render(wsproxy.DisplayName)),
IsConfirm: true,
Default: cliui.ConfirmNo,
})
if err != nil {
return err
}

err = client.DeleteWorkspaceProxyByName(ctx, inv.Args[0])
if err != nil {
return xerrors.Errorf("delete workspace proxy %q: %w", inv.Args[0], err)
}
Expand Down