Class Prompter

java.lang.Object
net.rubygrapefruit.platform.prompts.Prompter

public class Prompter extends Object
Displays prompts on the terminal to ask the user various kinds of questions.
  • Constructor Details

    • Prompter

      public Prompter(Terminals terminals)
  • Method Details

    • isInteractive

      public boolean isInteractive()
      Returns true if this prompter can ask the user questions.
    • select

      public Integer select(String prompt, List<String> options, int defaultOption)
      Asks the user to select an option from a list.
      Returns:
      The index of the selected option or null on end of input. Returns the default option when not interactive.
    • enterText

      public String enterText(String prompt, String defaultValue)
      Asks the user to enter some text.
      Returns:
      The text or null on end of input. Returns the default value when not interactive.
    • enterPassword

      public String enterPassword(String prompt)
      Asks the user to enter a password.
      Returns:
      The password or null on end of input or when not interactive or when not possible to prompt for a password without echoing the characters.
    • askYesNo

      public Boolean askYesNo(String prompt, boolean defaultValue)
      Asks the user a yes/no question.
      Returns:
      The selected value or null on end of input. Returns the default value when not interactive.