(choices []string, text string, prompt string)
| 518 | } |
| 519 | |
| 520 | func (cmd *LoginCommand) promptMenu(choices []string, text string, prompt string) (string, error) { |
| 521 | var choice string |
| 522 | var err error |
| 523 | |
| 524 | if len(choices) < 50 { |
| 525 | for { |
| 526 | cmd.UI.DisplayText(text) |
| 527 | choice, err = cmd.UI.DisplayTextMenu(choices, prompt) |
| 528 | if err != ui.ErrInvalidIndex { |
| 529 | break |
| 530 | } |
| 531 | } |
| 532 | } else { |
| 533 | cmd.UI.DisplayText(text) |
| 534 | cmd.UI.DisplayText("There are too many options to display; please type in the name.") |
| 535 | cmd.UI.DisplayNewline() |
| 536 | defaultChoice := "enter to skip" |
| 537 | choice, err = cmd.UI.DisplayOptionalTextPrompt(defaultChoice, prompt) |
| 538 | |
| 539 | if choice == defaultChoice { |
| 540 | return "", nil |
| 541 | } |
| 542 | if !contains(choices, choice) { |
| 543 | return "", ui.InvalidChoiceError{Choice: choice} |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | return choice, err |
| 548 | } |
| 549 | |
| 550 | func (cmd *LoginCommand) targetSpace(space resources.Space) { |
| 551 | cmd.Config.SetSpaceInformation(space.GUID, space.Name, true) |
no test coverage detected