MCPcopy Index your code
hub / github.com/cli/cli / NewCmdDelete

Function NewCmdDelete

pkg/cmd/gpg-key/delete/delete.go:25–55  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*DeleteOptions) error)

Source from the content-addressed store, hash-verified

23}
24
25func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Command {
26 opts := &DeleteOptions{
27 HttpClient: f.HttpClient,
28 Config: f.Config,
29 IO: f.IOStreams,
30 Prompter: f.Prompter,
31 }
32
33 cmd := &cobra.Command{
34 Use: "delete <key-id>",
35 Short: "Delete a GPG key from your GitHub account",
36 Args: cmdutil.ExactArgs(1, "cannot delete: key id required"),
37 RunE: func(cmd *cobra.Command, args []string) error {
38 opts.KeyID = args[0]
39
40 if !opts.IO.CanPrompt() && !opts.Confirmed {
41 return cmdutil.FlagErrorf("--yes required when not running interactively")
42 }
43
44 if runF != nil {
45 return runF(opts)
46 }
47 return deleteRun(opts)
48 },
49 }
50
51 cmd.Flags().BoolVar(&opts.Confirmed, "confirm", false, "Skip the confirmation prompt")
52 _ = cmd.Flags().MarkDeprecated("confirm", "use `--yes` instead")
53 cmd.Flags().BoolVarP(&opts.Confirmed, "yes", "y", false, "Skip the confirmation prompt")
54 return cmd
55}
56
57func deleteRun(opts *DeleteOptions) error {
58 httpClient, err := opts.HttpClient()

Callers 1

TestNewCmdDeleteFunction · 0.70

Calls 4

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

Tested by 1

TestNewCmdDeleteFunction · 0.56