(f factory.Factory)
| 24 | } |
| 25 | |
| 26 | func NewCmdList(f factory.Factory) *cobra.Command { |
| 27 | confirmFlags := question.NewConfirmFlags() |
| 28 | cmd := &cobra.Command{ |
| 29 | Use: "delete {<name> | <id> | <slug>}", |
| 30 | Short: "Delete a project", |
| 31 | Long: "Delete a project in Octopus Deploy", |
| 32 | Aliases: []string{"del", "rm", "remove"}, |
| 33 | Example: heredoc.Docf(` |
| 34 | %[1]s project delete |
| 35 | %[1]s project rm |
| 36 | `, constants.ExecutableName), |
| 37 | RunE: func(cmd *cobra.Command, args []string) error { |
| 38 | client, err := f.GetSpacedClient(apiclient.NewRequester(cmd)) |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | if len(args) == 0 { |
| 44 | args = append(args, "") |
| 45 | } |
| 46 | |
| 47 | opts := &DeleteOptions{ |
| 48 | Client: client, |
| 49 | Ask: f.Ask, |
| 50 | NoPrompt: !f.IsPromptEnabled(), |
| 51 | IdOrName: args[0], |
| 52 | ConfirmFlags: confirmFlags, |
| 53 | } |
| 54 | |
| 55 | return deleteRun(opts) |
| 56 | }, |
| 57 | } |
| 58 | |
| 59 | question.RegisterConfirmDeletionFlag(cmd, &confirmFlags.Confirm.Value, "project") |
| 60 | |
| 61 | return cmd |
| 62 | } |
| 63 | |
| 64 | func deleteRun(opts *DeleteOptions) error { |
| 65 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected