(f factory.Factory)
| 24 | } |
| 25 | |
| 26 | func NewCmdDelete(f factory.Factory) *cobra.Command { |
| 27 | confirmFlags := question.NewConfirmFlags() |
| 28 | cmd := &cobra.Command{ |
| 29 | Use: "delete {<name> | <id>}", |
| 30 | Short: "Delete a user", |
| 31 | Long: "Delete a user in Octopus Deploy", |
| 32 | Aliases: []string{"del", "rm", "remove"}, |
| 33 | Example: heredoc.Docf(` |
| 34 | %[1]s user delete some-user-name |
| 35 | %[1]s user rm Users-123 |
| 36 | `, constants.ExecutableName), |
| 37 | RunE: func(c *cobra.Command, args []string) error { |
| 38 | octopus, err := f.GetSpacedClient(apiclient.NewRequester(c)) |
| 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: octopus, |
| 49 | Ask: f.Ask, |
| 50 | NoPrompt: !f.IsPromptEnabled(), |
| 51 | UsernameOrId: args[0], |
| 52 | ConfirmFlags: confirmFlags, |
| 53 | } |
| 54 | |
| 55 | return deleteRun(opts) |
| 56 | }, |
| 57 | } |
| 58 | |
| 59 | question.RegisterConfirmDeletionFlag(cmd, &confirmFlags.Confirm.Value, "user") |
| 60 | |
| 61 | return cmd |
| 62 | } |
| 63 | |
| 64 | func deleteRun(opts *DeleteOptions) error { |
| 65 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected