Console (install4j API)
Description: declaration: package: com.install4j.api.screens, interface: Console

# Interface Console

All Superinterfaces:
  `ProgressInterface`

public interface Console extends ProgressInterface
A `Console` object allows you to display information to the user and request input when the installer or uninstaller is running in console mode. Installers or uninstallers must be started with the "-c" argument to run in console mode. A console object is passed to the `handleConsole` methods of screens and form components.

See Also:
  - `Screen.handleConsole(Console)`
  - `FormComponent.handleConsole(Console)`

- ## Field Summary

  ### Fields inherited from interface ProgressInterface

  `OVERWRITE_ALL, OVERWRITE_NEVER, OVERWRITE_NO, OVERWRITE_YES, RETRY_CANCEL, RETRY_NO, RETRY_YES`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `askDirectory(String message, String defaultValue)`
  Ask the user for a directory path.
  `String`
  `askFile(String message, String defaultValue)`
  Ask the user for a file path.
  `int[]`
  `askMultipleSelection(String message, String[] descriptions, String[] keys, int[] defaultValues, boolean oneLinePerOption)`
  Ask the user to select multiple elements from a list of options.
  `boolean`
  `askOkCancel(String message)`
  Ask the user a question that has to be answered with "OK" or "Cancel".
  `boolean`
  `askOkCancel(String message, boolean defaultValue)`
  Ask the user a question that has to be answered with "OK" or "Cancel".
  `int`
  `askOption(String message, String[] descriptions, String[] keys)`
  Ask the user a question with a fixed set of answers.
  `int`
  `askOption(String message, String[] descriptions, String[] keys, int defaultValue)`
  Ask the user a question with a fixed set of answers.
  `int`
  `askOption(String message, String[] descriptions, String[] keys, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption)`
  Ask the user a question with a fixed set of answers.
  `int`
  `askOption(String message, String[] descriptions, String[] keys, String[] helpTexts, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption)`
  Ask the user a question with a fixed set of answers.
  `String`
  `askPassword(String message, String defaultValue)`
  Ask the user to enter a password.
  `default boolean`
  `askProceedCancel(String message)`
  Ask the user a question that has to be answered with "Proceed" or "Cancel".
  `default boolean`
  `askProceedCancel(String message, boolean defaultValue)`
  Ask the user a question that has to be answered with "Proceed" or "Cancel".
  `String`
  `askString(String message, String defaultValue)`
  Ask the user to enter a string with a default string that can be accepted by the user.
  `boolean`
  `askYesNo(String message)`
  Ask the user a question that has to be answered with "Yes" or "No".
  `boolean`
  `askYesNo(String message, boolean defaultValue)`
  Ask the user a question that has to be answered with "Yes" or "No".
  `default boolean`
  `isRichConsole()`
  Returns whether this is a rich console that supports interactive prompts and styled output.
  `void`
  `more(String text)`
  Print a long text to the console and partition it into pages.
  `default void`
  `more(String text, boolean mustReachEnd)`
  Print a long text to the console and partition it into pages.
  `void`
  `print(Object val)`
  Print an object to the console by invoking its `toString()` method.
  `void`
  `printHeader(String title)`
  Print the header for a new screen.
  `void`
  `println()`
  Print a line feed to the console.
  `void`
  `println(Object val)`
  Print an object to the console by invoking its `toString()` method and append a line feed.
  `void`
  `println(Object val, MessageStatus status)`
  Print an object to the console with a status indicator and append a line feed.
  `String`
  `readLine()`
  Read input from the console.
  `void`
  `waitForEnter()`
  Print [Enter] to the console and wait for the user to hit the Enter key.

  ### Methods inherited from interface ProgressInterface

  `askContinue, askOverwrite, askRetry, clearProgress, getPercentCompleted, isAlertsShown, isUnattendedProgressDialog, setDetailMessage, setIndeterminateProgress, setPercentCompleted, setSecondaryPercentCompleted, setStatusMessage, showFailure`

- ## Method Details

  - ### print

    void print(Object val)
    Print an object to the console by invoking its `toString()` method.
    Parameters:
      `val` - the object to be printed

  - ### println

    void println(Object val)
    Print an object to the console by invoking its `toString()` method and append a line feed.
    Parameters:
      `val` - the object to be printed

  - ### println

    void println(Object val, MessageStatus status)
    Print an object to the console with a status indicator and append a line feed.
    Parameters:
      `val` - the object to be printed
      `status` - the status of the message

  - ### println

    void println()
    Print a line feed to the console.

  - ### isRichConsole

    default boolean isRichConsole()
    Returns whether this is a rich console that supports interactive prompts and styled output.
    Returns:
      `true` if this is a rich console

  - ### more

    void more(@Nls String text) throws UserCanceledException
    Print a long text to the console and partition it into pages. Line breaks are introduced after 75 characters, and a "more" notice is printed every 25 lines. In rich console mode, the actual terminal size is used instead.
    Parameters:
      `text` - the text
    Throws:
      `UserCanceledException` - if the user cancels the "more" notice, typically with CTRL-C

  - ### more

    default void more(@Nls String text, boolean mustReachEnd) throws UserCanceledException
    Print a long text to the console and partition it into pages. If `mustReachEnd` is `true`, the user must page through the entire text before being allowed to dismiss it.
    Parameters:
      `text` - the text
      `mustReachEnd` - whether the user must reach the end of the text before being allowed to quit
    Throws:
      `UserCanceledException` - if the user cancels the "more" notice, typically with CTRL-C

  - ### readLine

    String readLine() throws UserCanceledException
    Read input from the console.
    Returns:
      the string that was entered by the user.
    Throws:
      `UserCanceledException` - if the user cancels the prompt, typically with CTRL-C

  - ### askYesNo

    boolean askYesNo(@Nls String message) throws UserCanceledException
    Ask the user a question that has to be answered with "Yes" or "No". There is no default value.
    Parameters:
      `message` - the question
    Returns:
      whether the user answered "Yes"
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C

  - ### askYesNo

    boolean askYesNo(@Nls String message, boolean defaultValue) throws UserCanceledException
    Ask the user a question that has to be answered with "Yes" or "No". The default value is configurable.
    Parameters:
      `message` - the question
      `defaultValue` - whether "Yes" is the default value
    Returns:
      whether the user answered "Yes"
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C

  - ### askOkCancel

    boolean askOkCancel(@Nls String message) throws UserCanceledException
    Ask the user a question that has to be answered with "OK" or "Cancel". There is no default value.
    Parameters:
      `message` - the question
    Returns:
      whether the user answered "OK"
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.

  - ### askOkCancel

    boolean askOkCancel(@Nls String message, boolean defaultValue) throws UserCanceledException
    Ask the user a question that has to be answered with "OK" or "Cancel". The default value is configurable.
    Parameters:
      `message` - the question
      `defaultValue` - whether "OK" is the default value
    Returns:
      whether the user answered "OK"
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.

  - ### askProceedCancel

    default boolean askProceedCancel(@Nls String message) throws UserCanceledException
    Ask the user a question that has to be answered with "Proceed" or "Cancel". There is no default value.
    Parameters:
      `message` - the question
    Returns:
      whether the user answered "Proceed"
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.

  - ### askProceedCancel

    default boolean askProceedCancel(@Nls String message, boolean defaultValue) throws UserCanceledException
    Ask the user a question that has to be answered with "Proceed" or "Cancel". The default value is configurable.
    Parameters:
      `message` - the question
      `defaultValue` - whether "Proceed" is the default value
    Returns:
      whether the user answered "Proceed"
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.

  - ### askOption

    int askOption(@Nls String message, @Nls String[] descriptions, String[] keys) throws UserCanceledException
    Ask the user a question with a fixed set of answers. There is no default value.
    Parameters:
      `message` - the question
      `descriptions` - an array with a textual description for each option
      `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
    Returns:
      the selected index of the option
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### askOption

    int askOption(@Nls String message, @Nls String[] descriptions, String[] keys, int defaultValue) throws UserCanceledException
    Ask the user a question with a fixed set of answers. The default value is configurable.
    Parameters:
      `message` - the question
      `descriptions` - an array with a textual description for each option
      `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
      `defaultValue` - the index of the default option
    Returns:
      the selected index of the option
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### askOption

    int askOption(@Nls String message, @Nls String[] descriptions, String[] keys, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption) throws UserCanceledException
    Ask the user a question with a fixed set of answers. The default value, the no-selection policy as well as the presentation of the options are configurable.
    Parameters:
      `message` - the question
      `descriptions` - an array with a textual description for each option
      `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
      `defaultValue` - the index of the default option
      `allowNoSelection` - if the question should allow an empty answer, the return value is -1 in that case.
      `oneLinePerOption` - if the options should be presented one option per line. By default, all options are presented on the same line.
    Returns:
      the index of the selected option or -1 if no answer is given.
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### askOption

    int askOption(@Nls String message, @Nls String[] descriptions, String[] keys, @Nls String[] helpTexts, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption) throws UserCanceledException
    Ask the user a question with a fixed set of answers. The default value, the help texts, the no-selection policy as well as the presentation of the options are configurable.
    Parameters:
      `message` - the question
      `descriptions` - an array with a textual description for each option
      `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
      `helpTexts` - an array with help texts that can be shown by the user, array elements can be null for no help
      `defaultValue` - the index of the default option
      `allowNoSelection` - if the question should allow an empty answer, the return value is -1 in that case.
      `oneLinePerOption` - if the options should be presented one option per line. By default, all options are presented on the same line.
    Returns:
      the index of the selected option or -1 if no answer is given.
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### askMultipleSelection

    int[] askMultipleSelection(@Nls String message, @Nls String[] descriptions, String[] keys, int[] defaultValues, boolean oneLinePerOption) throws UserCanceledException
    Ask the user to select multiple elements from a list of options. The default selection and the presentation of the options are configurable.
    Parameters:
      `message` - the question
      `descriptions` - an array with a textual description for each option
      `keys` - an array with a short key for each option. Keys are what the user enters to select the desired options.
      `defaultValues` - an array with the indices of the options that are selected by default
      `oneLinePerOption` - if the options should be presented one option per line. By default, all options are presented on the same line.
    Returns:
      an array with the indices of the selected options. The length of the array can be zero if no options were selected.
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### askString

    String askString(@Nls String message, String defaultValue) throws UserCanceledException
    Ask the user to enter a string with a default string that can be accepted by the user.
    Parameters:
      `message` - the prompt before the input
      `defaultValue` - the default string
    Returns:
      the string entered by the user or the default value if the user hits the Enter key.
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### askFile

    String askFile(@Nls String message, String defaultValue) throws UserCanceledException
    Ask the user for a file path. In rich console mode, tab completion offers files and directories.
    Parameters:
      `message` - the prompt message
      `defaultValue` - the default value, or `null`
    Returns:
      the path entered by the user, or the default value if no input was given
    Throws:
      `UserCanceledException` - if the user cancels the prompt, typically with CTRL-C

  - ### askDirectory

    String askDirectory(@Nls String message, String defaultValue) throws UserCanceledException
    Ask the user for a directory path. In rich console mode, tab completion offers directories only.
    Parameters:
      `message` - the prompt message
      `defaultValue` - the default value, or `null`
    Returns:
      the path entered by the user, or the default value if no input was given
    Throws:
      `UserCanceledException` - if the user cancels the prompt, typically with CTRL-C

  - ### askPassword

    String askPassword(@Nls String message, String defaultValue) throws UserCanceledException
    Ask the user to enter a password.
    Parameters:
      `message` - the prompt before the input
      `defaultValue` - the default string
    Returns:
      the string entered by the user or the default value if the user hits the Enter key.
    Throws:
      `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

  - ### waitForEnter

    void waitForEnter() throws UserCanceledException
    Print [Enter] to the console and wait for the user to hit the Enter key.
    Throws:
      `UserCanceledException` - if the user cancels the notice, typically with CTRL-C.

  - ### printHeader

    void printHeader(@Nls String title) throws UserCanceledException
    Print the header for a new screen. This invokes the "Console screen change handler" that is set for the application node on the Screens & Actions tab. If that script is not configured, nothing will be printed.
    Parameters:
      `title` - the title
    Throws:
      `UserCanceledException` - if the user cancels the notice, typically with CTRL-C.