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

Function NewCmdDelete

pkg/cmd/user/delete/delete.go:26–62  ·  view source on GitHub ↗
(f factory.Factory)

Source from the content-addressed store, hash-verified

24}
25
26func 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
64func deleteRun(opts *DeleteOptions) error {
65 if !opts.NoPrompt {

Callers

nothing calls this directly

Calls 6

NewConfirmFlagsFunction · 0.92
NewRequesterFunction · 0.92
deleteRunFunction · 0.70
GetSpacedClientMethod · 0.65
IsPromptEnabledMethod · 0.65

Tested by

no test coverage detected