func (cmd *Target) Execute(c flags.FlagContext) error { orgName := c.String("o") spaceName := c.String("s") if orgName != "" { err := cmd.setOrganization(orgName) if err != nil { return err } 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 { return err } } err := cmd.ui.ShowConfiguration(cmd.config) if err != nil { return err } cmd.ui.NotifyUpdateIfNeeded(cmd.config) if !cmd.config.IsLoggedIn() { return fmt.Errorf(terminal.NotLoggedInText()) } return nil }
func (req LoginRequirement) Execute() error { if err := req.apiEndpointRequirement.Execute(); err != nil { return err } if !req.config.IsLoggedIn() { return errors.New(terminal.NotLoggedInText()) } return nil }