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