Class Prompt<TOption>
java.lang.Object
com.github.rvesse.airline.prompts.Prompt<TOption>
- Type Parameters:
TOption- Option type
Represents a prompt
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final TypeConverterprivate final ExecutorServiceprivate final PromptFormatterprivate final Stringprivate final PromptOptionMatcher<TOption> private final PromptProviderprivate final longprivate final TimeUnit -
Constructor Summary
ConstructorsConstructorDescriptionPrompt(PromptProvider provider, PromptFormatter formatter, long timeout, TimeUnit timeoutUnit, String promptMessage, Collection<TOption> options, PromptOptionMatcher<TOption> optionMatcher, boolean allowNumericOptionSelection, TypeConverter converter) Creates a new prompt -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets whether options can be selected numerically when usingpromptForOption(boolean)private voidDisplays the promptGets the prompt messageGets the available options (if any)Gets the prompt providerlongGets the configured timeoutGets the timeout unitGets the configured type converterintPrompts for a single keyPrompts for a line of inputpromptForOption(boolean secure) Prompts for optionchar[]Prompts for a secure input line<T> TpromptForValue(Class<T> cls, boolean secure) Prompts for a valueprotected <T> TwaitForPromptResponse(Future<T> future) Wait for a prompt response
-
Field Details
-
provider
-
formatter
-
timeout
private final long timeout -
allowNumericOptionSelection
private final boolean allowNumericOptionSelection -
timeoutUnit
-
executor
-
options
-
optionMatcher
-
message
-
converter
-
-
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 Providerformatter- Prompt Formattertimeout- TimeouttimeoutUnit- Timeout UnitpromptMessage- Prompt Messageoptions- OptionsoptionMatcher- Option matcherallowNumericOptionSelection- Whether numeric option selection is allowedconverter- Type converter
-
-
Method Details
-
getProvider
-
getMessage
-
allowsNumericOptionSelection
public boolean allowsNumericOptionSelection()Gets whether options can be selected numerically when usingpromptForOption(boolean)- Returns:
- True if numeric selection enabled, false otherwise
-
getOptions
-
getOptionMatcher
-
getTypeConverter
-
getTimeout
public long getTimeout()Gets the configured timeout- Returns:
- Configured timeout or 0 if no timeout
-
getTimeoutUnit
-
displayPrompt
private void displayPrompt()Displays the prompt -
waitForPromptResponse
Wait for a prompt response- Type Parameters:
T- Response type- Parameters:
future- Future- Returns:
- Response type
- Throws:
PromptException
-
promptForKey
Prompts for a single key- Returns:
- Key code
- Throws:
PromptException
-
promptForLine
Prompts for a line of input- Returns:
- Input line
- Throws:
PromptException
-
promptForOption
Prompts for option- Parameters:
secure- Does the response need to be secure?- Returns:
- Option value
- Throws:
PromptException
-
promptForValue
Prompts for a value- Type Parameters:
T- Value type- Parameters:
cls- Value type classsecure- Does the response need to be secure?- Returns:
- Value
- Throws:
PromptException
-
promptForSecure
Prompts for a secure input line- Returns:
- Input line
- Throws:
PromptException- Thrown if the underlying prompt provider does not support secure reads
-