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

Method promptMenu

command/v7/login_command.go:520–548  ·  view source on GitHub ↗
(choices []string, text string, prompt string)

Source from the content-addressed store, hash-verified

518}
519
520func (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
550func (cmd *LoginCommand) targetSpace(space resources.Space) {
551 cmd.Config.SetSpaceInformation(space.GUID, space.Name, true)

Callers 2

promptChosenOrgMethod · 0.95
promptChosenSpaceMethod · 0.95

Calls 5

containsFunction · 0.70
DisplayTextMethod · 0.65
DisplayTextMenuMethod · 0.65
DisplayNewlineMethod · 0.65

Tested by

no test coverage detected