MCPcopy
hub / github.com/cli/cli / NewCmdDelete

Function NewCmdDelete

pkg/cmd/issue/delete/delete.go:32–74  ·  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 Config: f.Config,
37 Prompter: f.Prompter,
38 }
39
40 cmd := &cobra.Command{
41 Use: "delete {<number> | <url>}",
42 Short: "Delete issue",
43 Args: cobra.ExactArgs(1),
44 RunE: func(cmd *cobra.Command, args []string) error {
45 issueNumber, baseRepo, err := shared.ParseIssueFromArg(args[0])
46 if err != nil {
47 return err
48 }
49
50 // If the args provided the base repo then use that directly.
51 if baseRepo, present := baseRepo.Value(); present {
52 opts.BaseRepo = func() (ghrepo.Interface, error) {
53 return baseRepo, nil
54 }
55 } else {
56 // support `-R, --repo` override
57 opts.BaseRepo = f.BaseRepo
58 }
59
60 opts.IssueNumber = issueNumber
61
62 if runF != nil {
63 return runF(opts)
64 }
65
66 return deleteRun(opts)
67 },
68 }
69
70 cmd.Flags().BoolVar(&opts.Confirmed, "confirm", false, "Confirm deletion without prompting")
71 _ = cmd.Flags().MarkDeprecated("confirm", "use `--yes` instead")
72 cmd.Flags().BoolVar(&opts.Confirmed, "yes", false, "Confirm deletion without prompting")
73 return cmd
74}
75
76func deleteRun(opts *DeleteOptions) error {
77 cs := opts.IO.ColorScheme()

Callers 1

runCommandFunction · 0.70

Calls 3

ParseIssueFromArgFunction · 0.92
ValueMethod · 0.80
deleteRunFunction · 0.70

Tested by 1

runCommandFunction · 0.56