Class Prompt

java.lang.Object
com.helixframework.console.Prompt

public class Prompt extends Object
Prompt class represents a command line prompt that reads user input from the console. The Prompt class provides methods to customize the prompt message, prefix, suffix, default value, required input, and text colors. It uses the ConsoleReader class for reading user input. Example usage: Prompt prompt = Prompt.builder(consoleReader, "Enter your name") .promptPrefix("> ") .promptSuffix(":") .defaultValue("John Doe") .optional() .promptColor(Colors.GREEN) .defaultValueColor(Colors.YELLOW) .build(); String name = prompt.read(); The Prompt class provides a fluent builder API to configure and create instances of Prompt.
  • Method Details

    • builder

      public static Prompt.Builder builder(jline.console.ConsoleReader reader, String prompt)
      Creates a new instance of Builder class to build a Prompt object.
      Parameters:
      reader - the ConsoleReader object to read user input from
      prompt - the prompt message displayed to the user
      Returns:
      a new instance of Builder class
    • read

      public String read() throws IOException
      Reads user input from the ConsoleReader object.
      Returns:
      the user input as a String
      Throws:
      IOException - if there is an error reading user input