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 boolean
private final TypeConverter
private final ExecutorService
private final PromptFormatter
private final String
private final PromptOptionMatcher
<TOption> private final PromptProvider
private final long
private 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 TypeMethodDescriptionboolean
Gets whether options can be selected numerically when usingpromptForOption(boolean)
private void
Displays the promptGets the prompt messageGets the available options (if any)Gets the prompt providerlong
Gets the configured timeoutGets the timeout unitGets the configured type converterint
Prompts for a single keyPrompts for a line of inputpromptForOption
(boolean secure) Prompts for optionchar[]
Prompts for a secure input line<T> T
promptForValue
(Class<T> cls, boolean secure) Prompts for a valueprotected <T> T
waitForPromptResponse
(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
Gets the prompt provider- Returns:
- Provider
-
getMessage
Gets the prompt message- Returns:
- Message
-
allowsNumericOptionSelection
public boolean allowsNumericOptionSelection()Gets whether options can be selected numerically when usingpromptForOption(boolean)
- Returns:
- True if numeric selection enabled, false otherwise
-
getOptions
Gets the available options (if any)- Returns:
- Options
-
getOptionMatcher
-
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
Gets the timeout unit- Returns:
- Timeout unit
-
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
-