MCPcopy Create free account
hub / github.com/cli/cli / deleteRun

Function deleteRun

pkg/cmd/event/subscription/delete/delete.go:60–87  ·  view source on GitHub ↗
(ctx context.Context, opts *DeleteOptions)

Source from the content-addressed store, hash-verified

58}
59
60func deleteRun(ctx context.Context, opts *DeleteOptions) error {
61 cfg, err := opts.Config()
62 if err != nil {
63 return err
64 }
65 host, _ := cfg.Authentication().DefaultHost()
66
67 c, err := opts.EventClient(host)
68 if err != nil {
69 return err
70 }
71
72 opts.IO.StartProgressIndicator()
73 err = c.DeleteSubscription(ctx, opts.ID)
74 opts.IO.StopProgressIndicator()
75 if err != nil {
76 if errors.Is(err, client.ErrSubscriptionNotFound) {
77 return shared.SubscriptionNotFoundError(opts.ID)
78 }
79 return fmt.Errorf("failed to delete subscription: %w", err)
80 }
81
82 if opts.IO.IsStderrTTY() {
83 cs := opts.IO.ColorScheme()
84 fmt.Fprintf(opts.IO.ErrOut, "%s Deleted subscription %s\n", cs.SuccessIconWithColor(cs.Red), opts.ID)
85 }
86 return nil
87}

Callers 2

NewCmdDeleteFunction · 0.70
TestDeleteRunFunction · 0.70

Calls 11

IsStderrTTYMethod · 0.80
ColorSchemeMethod · 0.80
SuccessIconWithColorMethod · 0.80
ConfigMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65
DeleteSubscriptionMethod · 0.65
StopProgressIndicatorMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestDeleteRunFunction · 0.56