Class ConsoleIkePrompter

java.lang.Object
network.ike.plugin.support.ConsoleIkePrompter
All Implemented Interfaces:
IkePrompter

public final class ConsoleIkePrompter extends Object implements IkePrompter
Environment-aware IkePrompter (IKE-Network/ike-issues#385).

Detects the input channel with System.console() and renders accordingly:

  • System.console() != null — a real terminal (a shell, or IntelliJ's Terminal tool window). The label is written and the input read through Console, so the prompt renders inline with the cursor.
  • System.console() == null — a piped runner (IntelliJ's Maven tool window). The label is written through the Maven Log — the one channel a piped IDE console renders correctly and in order with [INFO] output — and input is read from System.in. The label lands on its own line: visible, ordered, answerable.

The Maven 4 Prompter service is intentionally not used: it writes through JLine to raw file descriptors, uncoordinated with the logger, and misrenders in piped runners.

  • Constructor Details

    • ConsoleIkePrompter

      public ConsoleIkePrompter(org.apache.maven.api.plugin.Log log, boolean interactive)
      Creates a prompter.
      Parameters:
      log - the Maven logger — used for the own-line label in the piped (non-console) case
      interactive - whether Maven is in an interactive context; pass false for batch mode (the prompter then declines all prompts)
  • Method Details

    • isInteractive

      public boolean isInteractive()
      Description copied from interface: IkePrompter
      Whether an interactive input channel is available.

      False in genuine non-interactive contexts (Maven batch mode); a goal should then fail with a -D<param>= instruction rather than prompt.

      Specified by:
      isInteractive in interface IkePrompter
      Returns:
      true when prompting is possible
    • prompt

      public String prompt(String label)
      Description copied from interface: IkePrompter
      Prompts for a free-text line of input.
      Specified by:
      prompt in interface IkePrompter
      Parameters:
      label - the prompt label, including any trailing separator (e.g. "Commit message: ")
      Returns:
      the entered line (trimmed), or null if input was blank, end-of-stream, or not interactive
    • confirm

      public boolean confirm(String label, boolean defaultYes)
      Description copied from interface: IkePrompter
      Prompts for a yes/no confirmation.
      Specified by:
      confirm in interface IkePrompter
      Parameters:
      label - the question
      defaultYes - the answer assumed on blank input or a non-interactive context
      Returns:
      the user's choice, or defaultYes as the default
    • select

      public String select(String label, List<String> options)
      Description copied from interface: IkePrompter
      Prompts for a numbered selection from a list.
      Specified by:
      select in interface IkePrompter
      Parameters:
      label - the selection header
      options - the choices, rendered as a numbered list
      Returns:
      the chosen option, or null on invalid, blank, or non-interactive input