Forge - Parent 1.0.7-SNAPSHOT

org.jboss.forge.shell
Interface ShellPrompt

All Known Subinterfaces:
Shell

public interface ShellPrompt

Author:
Lincoln Baxter, III

Method Summary
 String prompt()
          Prompt for user input, and return as a String.
 String prompt(String message)
          Prompt for user input, first printing the given line, then return user input as a String.
<T> T
prompt(String message, Class<T> clazz)
          Prompt for user input, first printing the given message, then return user input cast to the type provided.
<T> T
prompt(String message, Class<T> clazz, T defaultIfEmpty)
          Prompt for user input, first printing the given line, then returning user input as a converted value.
 String prompt(String message, String defaultIfEmpty)
          Prompt for user input, first printing the given line, then return user input as a String.
 String promptAndSwallowCR()
          This works like prompt, however when a CR is received, the method returns the value, but does not produce a CR in the actual terminal buffer.
 boolean promptBoolean(String string)
          Prompt for boolean user input (Y/n), first printing the given message, then returning user input as a boolean.
 boolean promptBoolean(String message, boolean defaultIfEmpty)
          Prompt for boolean user input (Y/n), first printing the given message, then returning user input as a boolean.
 int promptChoice(String message, List<?> options)
          Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return the index of that option from the list.
<T> T
promptChoice(String message, Map<String,T> options)
          Prompt for user input, first printing the given message, followed by a keyed list of options.
 int promptChoice(String message, Object... options)
          Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return the index of that option from the list.
<T> T
promptChoiceTyped(String message, List<T> options)
          Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return that option from the list.
<T> T
promptChoiceTyped(String message, List<T> options, T defaultIfEmpty)
          Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return that option from the list.
 String promptCommon(String message, PromptType type)
          Prompt for user input, first printing the given message, then returning user input as a String.
 String promptCommon(String message, PromptType type, String defaultIfEmpty)
          Same as promptCommon(String, PromptType), but will default to a given value if user input is empty.
 String promptCompleter(String string, Class<? extends CommandCompleter> type)
          Prompt for user input, first printing the given line, then returning user input with help from the given completer type.
<T extends Enum<T>>
T
promptEnum(String message, Class<T> type)
          Prompt for user input in the form of an Enum, first printing the given message, then returning user input as a Enum.
<T extends Enum<T>>
T
promptEnum(String message, Class<T> type, T defaultIfEmpty)
          Prompt for user input in the form of an Enum, first printing the given message, then returning user input as a Enum.
 FileResource<?> promptFile(String message)
          Prompt for user input in the form of a file path, first printing the given message, then returning user input as a File.
 FileResource<?> promptFile(String message, FileResource<?> defaultIfEmpty)
          Prompt for user input in the form of a file path, first printing the given message, then returning user input as a File.
 String promptRegex(String message, String regex)
          Prompt for user input (Y/n), first printing the given message, then returning user input as a String.
 String promptRegex(String message, String pattern, String defaultIfEmpty)
          Same as promptRegex(String, String), but will default to a given value if user input is empty.
 String promptSecret(String message)
          First print the given message, prompt the user for input (masking keystrokes for secrecy,) then return user input.
 String promptSecret(String string, String defaultIfEmpty)
          First print the given message, prompt the user for input (masking keystrokes for secrecy,) then return user input.
 

Method Detail

prompt

String prompt()
Prompt for user input, and return as a String.


promptAndSwallowCR

String promptAndSwallowCR()
This works like prompt, however when a CR is received, the method returns the value, but does not produce a CR in the actual terminal buffer. This is useful when a plugin is using manual cursor control.

Returns:

prompt

String prompt(String message)
Prompt for user input, first printing the given line, then return user input as a String.


prompt

String prompt(String message,
              String defaultIfEmpty)
Prompt for user input, first printing the given line, then return user input as a String.

Parameters:
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

prompt

<T> T prompt(String message,
             Class<T> clazz)
Prompt for user input, first printing the given message, then return user input cast to the type provided.


promptBoolean

boolean promptBoolean(String string)
Prompt for boolean user input (Y/n), first printing the given message, then returning user input as a boolean. The value returned will default to true if an empty or whitespace-only user input is read.


promptBoolean

boolean promptBoolean(String message,
                      boolean defaultIfEmpty)
Prompt for boolean user input (Y/n), first printing the given message, then returning user input as a boolean.

Parameters:
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

promptChoice

int promptChoice(String message,
                 Object... options)
Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return the index of that option from the list.

Parameters:
message - The prompt message to display until valid input is entered
options - The list of selection options
Returns:
the index of selected option

promptChoice

int promptChoice(String message,
                 List<?> options)
Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return the index of that option from the list.

Parameters:
message - The prompt message to display until valid input is entered
options - The list of selection options
Returns:
the index of the selected option

promptChoiceTyped

<T> T promptChoiceTyped(String message,
                        List<T> options)
Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return that option from the list.

Type Parameters:
T - The type of the objects contained in the list
Parameters:
message - The prompt message to display until valid input is entered
options - The list of selection options
Returns:
the selected option

promptChoiceTyped

<T> T promptChoiceTyped(String message,
                        List<T> options,
                        T defaultIfEmpty)
Prompt for user input, first printing the given message, followed by an enumerated list of options (printing the String value of each item in the list.) Loop until the user enters a number corresponding to one of the options, then return that option from the list.

Type Parameters:
T - The type of the objects contained in the list
Parameters:
message - The prompt message to display until valid input is entered
options - The list of selection options
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.
Returns:
the selected option

promptChoice

<T> T promptChoice(String message,
                   Map<String,T> options)
Prompt for user input, first printing the given message, followed by a keyed list of options. Loop until the user enters a key corresponding to one of the options, then return the value of that option from the map.

Type Parameters:
T - The type of the objects contained in the map
Parameters:
message - The prompt message to display until valid input is entered
options - The map of selection options
Returns:
the selected option

promptCommon

String promptCommon(String message,
                    PromptType type)
Prompt for user input, first printing the given message, then returning user input as a String. The prompt will repeat until input matching the prompt type is entered.

Parameters:
message - The prompt message to display until valid input is entered
type - The prompt type to which valid input must be matched

promptEnum

<T extends Enum<T>> T promptEnum(String message,
                                 Class<T> type)
Prompt for user input in the form of an Enum, first printing the given message, then returning user input as a Enum. The prompt will repeat until input matching the prompt type is entered.

Parameters:
message - The prompt message to display until valid input is entered

promptEnum

<T extends Enum<T>> T promptEnum(String message,
                                 Class<T> type,
                                 T defaultIfEmpty)
Prompt for user input in the form of an Enum, first printing the given message, then returning user input as a Enum. The prompt will repeat until input matching the prompt type is entered.

Parameters:
message - The prompt message to display until valid input is entered
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

promptFile

FileResource<?> promptFile(String message)
Prompt for user input in the form of a file path, first printing the given message, then returning user input as a File. The prompt will repeat until input matching the prompt type is entered.

Parameters:
message - The prompt message to display until valid input is entered

promptFile

FileResource<?> promptFile(String message,
                           FileResource<?> defaultIfEmpty)
Prompt for user input in the form of a file path, first printing the given message, then returning user input as a File. The prompt will repeat until input matching the prompt type is entered.

Parameters:
message - The prompt message to display until valid input is entered
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

promptCommon

String promptCommon(String message,
                    PromptType type,
                    String defaultIfEmpty)
Same as promptCommon(String, PromptType), but will default to a given value if user input is empty.

Parameters:
message - The prompt message to display until valid input is entered
type - The prompt type to which valid input must be matched
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

promptRegex

String promptRegex(String message,
                   String regex)
Prompt for user input (Y/n), first printing the given message, then returning user input as a String. The prompt will repeat until input matching the regular expression is entered.

Parameters:
message - The prompt message to display until valid input is entered
regex - The regular expression to which valid input must be matched

promptRegex

String promptRegex(String message,
                   String pattern,
                   String defaultIfEmpty)
Same as promptRegex(String, String), but will default to a given value if user input is empty.

Parameters:
message - The prompt message to display until valid input is entered
pattern - The regular expression to which valid input must be matched
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

prompt

<T> T prompt(String message,
             Class<T> clazz,
             T defaultIfEmpty)
Prompt for user input, first printing the given line, then returning user input as a converted value.

Parameters:
clazz - The type to which the value will be converted, if possible.
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

promptCompleter

String promptCompleter(String string,
                       Class<? extends CommandCompleter> type)
Prompt for user input, first printing the given line, then returning user input with help from the given completer type.

Parameters:
message - The prompt message to display until valid input is entered
type - The command completer type to instantiate and use during completion

promptSecret

String promptSecret(String message)
First print the given message, prompt the user for input (masking keystrokes for secrecy,) then return user input.


promptSecret

String promptSecret(String string,
                    String defaultIfEmpty)
First print the given message, prompt the user for input (masking keystrokes for secrecy,) then return user input.

Parameters:
defaultIfEmpty - The value to be returned when an empty or whitespace-only user input is read.

Forge - Parent 1.0.7-SNAPSHOT

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.