@@ -23,18 +23,20 @@ import (
2323)
2424
2525const (
26- fallbackSuccessMessage = "'%s' deleted\n "
27- fallbackFailMessage = "Entry not deleted"
26+ fallbackSuccessMessage = "'%s' deleted\n "
27+ fallbackFailMessage = "Entry not deleted"
28+ defaultConfirmationPrompt = "Are you sure you want to delete: %s"
2829)
2930
3031// DeleteOpts options required when deleting a resource.
3132// A command can compose this struct and then safely rely on the methods Prompt, or Delete
3233// to manage the interactions with the user.
3334type DeleteOpts struct {
34- Entry string
35- Confirm bool
36- successMsg string
37- failMsg string
35+ Entry string
36+ Confirm bool
37+ confirmationPrompt string
38+ successMsg string
39+ failMsg string
3840}
3941
4042func NewDeleteOpts (successMsg , failMsg string ) * DeleteOpts {
@@ -44,6 +46,14 @@ func NewDeleteOpts(successMsg, failMsg string) *DeleteOpts {
4446 }
4547}
4648
49+ func NewDeleteOptsWithPrompt (successMsg , failMsg , confirmationPrompt string ) * DeleteOpts {
50+ return & DeleteOpts {
51+ successMsg : successMsg ,
52+ failMsg : failMsg ,
53+ confirmationPrompt : confirmationPrompt ,
54+ }
55+ }
56+
4757// Delete deletes a resource not associated to a project, it expects a callback
4858// that should perform the deletion from the store.
4959func (opts * DeleteOpts ) Delete (d any , a ... string ) error {
@@ -86,7 +96,13 @@ func (opts *DeleteOpts) Prompt() error {
8696 return nil
8797 }
8898
89- p := prompt .NewDeleteConfirm (opts .Entry )
99+ var template = opts .confirmationPrompt
100+ if template == "" {
101+ template = defaultConfirmationPrompt
102+ }
103+
104+ message := fmt .Sprintf (template , opts .Entry )
105+ p := prompt .NewConfirm (message )
90106 return telemetry .TrackAskOne (p , & opts .Confirm )
91107}
92108
0 commit comments