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

Function NewCmdDelete

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

Source from the content-addressed store, hash-verified

27}
28
29func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Command {
30 opts := &DeleteOptions{
31 IO: f.IOStreams,
32 Config: f.Config,
33 HttpClient: f.HttpClient,
34 }
35
36 cmd := &cobra.Command{
37 Use: "delete <variable-name>",
38 Short: "Delete variables",
39 Long: heredoc.Doc(`
40 Delete a variable on one of the following levels:
41 - repository (default): available to GitHub Actions runs or Dependabot in a repository
42 - environment: available to GitHub Actions runs for a deployment environment in a repository
43 - organization: available to GitHub Actions runs or Dependabot within an organization
44 `),
45 Args: cobra.ExactArgs(1),
46 RunE: func(cmd *cobra.Command, args []string) error {
47 // support `-R, --repo` override
48 opts.BaseRepo = f.BaseRepo
49
50 if err := cmdutil.MutuallyExclusive("specify only one of `--org` or `--env`", opts.OrgName != "", opts.EnvName != ""); err != nil {
51 return err
52 }
53
54 opts.VariableName = args[0]
55
56 if runF != nil {
57 return runF(opts)
58 }
59
60 return removeRun(opts)
61 },
62 Aliases: []string{
63 "remove",
64 },
65 }
66 cmd.Flags().StringVarP(&opts.OrgName, "org", "o", "", "Delete a variable for an organization")
67 cmd.Flags().StringVarP(&opts.EnvName, "env", "e", "", "Delete a variable for an environment")
68
69 return cmd
70}
71
72func removeRun(opts *DeleteOptions) error {
73 c, err := opts.HttpClient()

Callers 1

TestNewCmdDeleteFunction · 0.70

Calls 2

MutuallyExclusiveFunction · 0.92
removeRunFunction · 0.70

Tested by 1

TestNewCmdDeleteFunction · 0.56