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

Function NewCmdDelete

pkg/cmd/run/delete/delete.go:32–71  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*DeleteOptions) error)

Source from the content-addressed store, hash-verified

30}
31
32func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Command {
33 opts := &DeleteOptions{
34 IO: f.IOStreams,
35 HttpClient: f.HttpClient,
36 Prompter: f.Prompter,
37 }
38
39 cmd := &cobra.Command{
40 Use: "delete [<run-id>]",
41 Short: "Delete a workflow run",
42 Example: heredoc.Doc(`
43 # Interactively select a run to delete
44 $ gh run delete
45
46 # Delete a specific run
47 $ gh run delete 12345
48 `),
49 Args: cobra.MaximumNArgs(1),
50 RunE: func(cmd *cobra.Command, args []string) error {
51 // support `-R, --repo` override
52 opts.BaseRepo = f.BaseRepo
53
54 if len(args) > 0 {
55 opts.RunID = args[0]
56 } else if !opts.IO.CanPrompt() {
57 return cmdutil.FlagErrorf("run ID required when not running interactively")
58 } else {
59 opts.Prompt = true
60 }
61
62 if runF != nil {
63 return runF(opts)
64 }
65
66 return runDelete(opts)
67 },
68 }
69
70 return cmd
71}
72
73func runDelete(opts *DeleteOptions) error {
74 httpClient, err := opts.HttpClient()

Callers 1

TestNewCmdDeleteFunction · 0.70

Calls 3

FlagErrorfFunction · 0.92
CanPromptMethod · 0.80
runDeleteFunction · 0.70

Tested by 1

TestNewCmdDeleteFunction · 0.56