| 33 | } |
| 34 | |
| 35 | func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Command { |
| 36 | opts := &DeleteOptions{ |
| 37 | IO: f.IOStreams, |
| 38 | HttpClient: f.HttpClient, |
| 39 | GitClient: f.GitClient, |
| 40 | Prompter: f.Prompter, |
| 41 | } |
| 42 | |
| 43 | cmd := &cobra.Command{ |
| 44 | Use: "delete <tag>", |
| 45 | Short: "Delete a release", |
| 46 | Args: cobra.ExactArgs(1), |
| 47 | RunE: func(cmd *cobra.Command, args []string) error { |
| 48 | // support `-R, --repo` override |
| 49 | opts.BaseRepo = f.BaseRepo |
| 50 | opts.RepoOverride, _ = cmd.Flags().GetString("repo") |
| 51 | |
| 52 | opts.TagName = args[0] |
| 53 | |
| 54 | if runF != nil { |
| 55 | return runF(opts) |
| 56 | } |
| 57 | return deleteRun(opts) |
| 58 | }, |
| 59 | } |
| 60 | |
| 61 | cmd.Flags().BoolVarP(&opts.SkipConfirm, "yes", "y", false, "Skip the confirmation prompt") |
| 62 | cmd.Flags().BoolVar(&opts.CleanupTag, "cleanup-tag", false, "Delete the specified tag in addition to its release") |
| 63 | |
| 64 | return cmd |
| 65 | } |
| 66 | |
| 67 | func deleteRun(opts *DeleteOptions) error { |
| 68 | httpClient, err := opts.HttpClient() |