Skip to content

Commit 7a073e8

Browse files
committed
chore: add confirm delete to workspace proxy delete cli
1 parent aac4738 commit 7a073e8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

enterprise/cli/workspaceproxy.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,32 @@ func (r *RootCmd) deleteProxy() *clibase.Cmd {
189189
cmd := &clibase.Cmd{
190190
Use: "delete <name|id>",
191191
Short: "Delete a workspace proxy",
192+
Options: clibase.OptionSet{
193+
cliui.SkipPromptOption(),
194+
},
192195
Middleware: clibase.Chain(
193196
clibase.RequireNArgs(1),
194197
r.InitClient(client),
195198
),
196199
Handler: func(inv *clibase.Invocation) error {
197200
ctx := inv.Context()
198-
err := client.DeleteWorkspaceProxyByName(ctx, inv.Args[0])
201+
202+
wsproxy, err := client.WorkspaceProxyByName(ctx, inv.Args[0])
203+
if err != nil {
204+
return xerrors.Errorf("fetch workspace proxy %q: %w", inv.Args[0], err)
205+
}
206+
207+
// Confirm deletion of the template.
208+
_, err = cliui.Prompt(inv, cliui.PromptOptions{
209+
Text: fmt.Sprintf("Delete this workspace proxy: %s?", cliui.DefaultStyles.Code.Render(wsproxy.DisplayName)),
210+
IsConfirm: true,
211+
Default: cliui.ConfirmNo,
212+
})
213+
if err != nil {
214+
return err
215+
}
216+
217+
err = client.DeleteWorkspaceProxyByName(ctx, inv.Args[0])
199218
if err != nil {
200219
return xerrors.Errorf("delete workspace proxy %q: %w", inv.Args[0], err)
201220
}

0 commit comments

Comments
 (0)