MCPcopy
hub / github.com/cli/cli / newCmdDelete

Function newCmdDelete

pkg/cmd/label/delete.go:28–60  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*deleteOptions) error)

Source from the content-addressed store, hash-verified

26}
27
28func newCmdDelete(f *cmdutil.Factory, runF func(*deleteOptions) error) *cobra.Command {
29 opts := deleteOptions{
30 HttpClient: f.HttpClient,
31 IO: f.IOStreams,
32 Prompter: f.Prompter,
33 }
34
35 cmd := &cobra.Command{
36 Use: "delete <name>",
37 Short: "Delete a label from a repository",
38 Args: cmdutil.ExactArgs(1, "cannot delete label: name argument required"),
39 RunE: func(c *cobra.Command, args []string) error {
40 // support `-R, --repo` override
41 opts.BaseRepo = f.BaseRepo
42 opts.Name = args[0]
43
44 if !opts.IO.CanPrompt() && !opts.Confirmed {
45 return cmdutil.FlagErrorf("--yes required when not running interactively")
46 }
47
48 if runF != nil {
49 return runF(&opts)
50 }
51 return deleteRun(&opts)
52 },
53 }
54
55 cmd.Flags().BoolVar(&opts.Confirmed, "confirm", false, "Confirm deletion without prompting")
56 _ = cmd.Flags().MarkDeprecated("confirm", "use `--yes` instead")
57 cmd.Flags().BoolVar(&opts.Confirmed, "yes", false, "Confirm deletion without prompting")
58
59 return cmd
60}
61
62func deleteRun(opts *deleteOptions) error {
63 httpClient, err := opts.HttpClient()

Callers 2

NewCmdLabelFunction · 0.85
TestNewCmdDeleteFunction · 0.85

Calls 4

ExactArgsFunction · 0.92
FlagErrorfFunction · 0.92
CanPromptMethod · 0.80
deleteRunFunction · 0.70

Tested by 1

TestNewCmdDeleteFunction · 0.68