MCPcopy Index your code
hub / github.com/cloudfoundry/cli / Execute

Method Execute

cf/commands/user/create_user.go:58–84  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

56}
57
58func (cmd *CreateUser) Execute(c flags.FlagContext) error {
59 username := c.Args()[0]
60 password := c.Args()[1]
61
62 cmd.ui.Say(T("Creating user {{.TargetUser}}...",
63 map[string]interface{}{
64 "TargetUser": terminal.EntityNameColor(username),
65 "CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
66 }))
67
68 err := cmd.userRepo.Create(username, password)
69 switch err.(type) {
70 case nil:
71 case *errors.ModelAlreadyExistsError:
72 cmd.ui.Warn("%s", err.Error())
73 default:
74 return errors.New(T("Error creating user {{.TargetUser}}.\n{{.Error}}",
75 map[string]interface{}{
76 "TargetUser": terminal.EntityNameColor(username),
77 "Error": err.Error(),
78 }))
79 }
80
81 cmd.ui.Ok()
82 cmd.ui.Say(T("\nTIP: Assign roles with '{{.CurrentUser}} set-org-role' and '{{.CurrentUser}} set-space-role'", map[string]interface{}{"CurrentUser": cf.Name}))
83 return nil
84}

Callers

nothing calls this directly

Calls 9

EntityNameColorFunction · 0.92
NewFunction · 0.92
ArgsMethod · 0.65
SayMethod · 0.65
UsernameMethod · 0.65
CreateMethod · 0.65
WarnMethod · 0.65
ErrorMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected