java.lang.Object
com.github.rvesse.airline.prompts.Prompt<TOption>
Type Parameters:
TOption - Option type

public class Prompt<TOption> extends Object
Represents a prompt
  • Field Details

  • Constructor Details

    • Prompt

      public Prompt(PromptProvider provider, PromptFormatter formatter, long timeout, TimeUnit timeoutUnit, String promptMessage, Collection<TOption> options, PromptOptionMatcher<TOption> optionMatcher, boolean allowNumericOptionSelection, TypeConverter converter)
      Creates a new prompt
      Parameters:
      provider - Prompt Provider
      formatter - Prompt Formatter
      timeout - Timeout
      timeoutUnit - Timeout Unit
      promptMessage - Prompt Message
      options - Options
      optionMatcher - Option matcher
      allowNumericOptionSelection - Whether numeric option selection is allowed
      converter - Type converter
  • Method Details

    • getProvider

      public PromptProvider getProvider()
      Gets the prompt provider
      Returns:
      Provider
    • getMessage

      public String getMessage()
      Gets the prompt message
      Returns:
      Message
    • allowsNumericOptionSelection

      public boolean allowsNumericOptionSelection()
      Gets whether options can be selected numerically when using promptForOption(boolean)
      Returns:
      True if numeric selection enabled, false otherwise
    • getOptions

      public List<TOption> getOptions()
      Gets the available options (if any)
      Returns:
      Options
    • getOptionMatcher

      public PromptOptionMatcher<TOption> getOptionMatcher()
    • getTypeConverter

      public TypeConverter getTypeConverter()
      Gets the configured type converter
      Returns:
      Type converter
    • getTimeout

      public long getTimeout()
      Gets the configured timeout
      Returns:
      Configured timeout or 0 if no timeout
    • getTimeoutUnit

      public TimeUnit getTimeoutUnit()
      Gets the timeout unit
      Returns:
      Timeout unit
    • displayPrompt

      private void displayPrompt()
      Displays the prompt
    • waitForPromptResponse

      protected <T> T waitForPromptResponse(Future<T> future) throws PromptException
      Wait for a prompt response
      Type Parameters:
      T - Response type
      Parameters:
      future - Future
      Returns:
      Response type
      Throws:
      PromptException
    • promptForKey

      public int promptForKey() throws PromptException
      Prompts for a single key
      Returns:
      Key code
      Throws:
      PromptException
    • promptForLine

      public String promptForLine() throws PromptException
      Prompts for a line of input
      Returns:
      Input line
      Throws:
      PromptException
    • promptForOption

      public TOption promptForOption(boolean secure) throws PromptException
      Prompts for option
      Parameters:
      secure - Does the response need to be secure?
      Returns:
      Option value
      Throws:
      PromptException
    • promptForValue

      public <T> T promptForValue(Class<T> cls, boolean secure) throws PromptException
      Prompts for a value
      Type Parameters:
      T - Value type
      Parameters:
      cls - Value type class
      secure - Does the response need to be secure?
      Returns:
      Value
      Throws:
      PromptException
    • promptForSecure

      public char[] promptForSecure() throws PromptException
      Prompts for a secure input line
      Returns:
      Input line
      Throws:
      PromptException - Thrown if the underlying prompt provider does not support secure reads