func (cmd Target) Run(c *cli.Context) { orgName := c.String("o") spaceName := c.String("s") if orgName != "" { err := cmd.setOrganization(orgName) if err != nil { cmd.ui.Failed(err.Error()) } else if spaceName == "" { spaceList, apiErr := cmd.getSpaceList() if apiErr == nil && len(spaceList) == 1 { cmd.setSpace(spaceList[0].Name) } } } if spaceName != "" { err := cmd.setSpace(spaceName) if err != nil { cmd.ui.Failed(err.Error()) } } cmd.ui.ShowConfiguration(cmd.config) if !cmd.config.IsLoggedIn() { cmd.ui.PanicQuietly() } utils.NotifyUpdateIfNeeded(cmd.ui, cmd.config) return }
func (cmd Authenticate) Run(c *cli.Context) { cmd.config.ClearSession() cmd.authenticator.GetLoginPromptsAndSaveUAAServerURL() cmd.ui.Say(T("API endpoint: {{.ApiEndpoint}}", map[string]interface{}{"ApiEndpoint": terminal.EntityNameColor(cmd.config.ApiEndpoint())})) cmd.ui.Say(T("Authenticating...")) apiErr := cmd.authenticator.Authenticate(map[string]string{"username": c.Args()[0], "password": c.Args()[1]}) if apiErr != nil { cmd.ui.Failed(apiErr.Error()) return } cmd.ui.Ok() cmd.ui.Say(T("Use '{{.Name}}' to view or set your target org and space", map[string]interface{}{"Name": terminal.CommandColor(cf.Name() + " target")})) utils.NotifyUpdateIfNeeded(cmd.ui, cmd.config) return }