MCPcopy
hub / github.com/cli/cli / deleteRun

Function deleteRun

pkg/cmd/repo/autolink/delete/delete.go:72–107  ·  view source on GitHub ↗
(opts *deleteOptions)

Source from the content-addressed store, hash-verified

70}
71
72func deleteRun(opts *deleteOptions) error {
73 repo, err := opts.BaseRepo()
74 if err != nil {
75 return err
76 }
77
78 out := opts.IO.Out
79 cs := opts.IO.ColorScheme()
80
81 autolink, err := opts.AutolinkViewClient.View(repo, opts.ID)
82
83 if err != nil {
84 return fmt.Errorf("%s %w", cs.Red("error deleting autolink:"), err)
85 }
86
87 if opts.IO.CanPrompt() && !opts.Confirmed {
88 fmt.Fprintf(out, "Autolink %s has key prefix %s.\n", cs.Cyan(opts.ID), autolink.KeyPrefix)
89
90 err := opts.Prompter.ConfirmDeletion(autolink.KeyPrefix)
91
92 if err != nil {
93 return err
94 }
95 }
96
97 err = opts.AutolinkDeleteClient.Delete(repo, opts.ID)
98 if err != nil {
99 return err
100 }
101
102 if opts.IO.IsStdoutTTY() {
103 fmt.Fprintf(out, "%s Autolink %s deleted from %s\n", cs.SuccessIcon(), cs.Cyan(opts.ID), cs.Bold(ghrepo.FullName(repo)))
104 }
105
106 return nil
107}

Callers 2

NewCmdDeleteFunction · 0.70
TestDeleteRunFunction · 0.70

Calls 13

FullNameFunction · 0.92
ColorSchemeMethod · 0.80
RedMethod · 0.80
CanPromptMethod · 0.80
CyanMethod · 0.80
IsStdoutTTYMethod · 0.80
SuccessIconMethod · 0.80
BoldMethod · 0.80
BaseRepoMethod · 0.65
ViewMethod · 0.65
ErrorfMethod · 0.65
ConfirmDeletionMethod · 0.65

Tested by 1

TestDeleteRunFunction · 0.56