Class ConsoleIkePrompter
java.lang.Object
network.ike.plugin.support.ConsoleIkePrompter
- All Implemented Interfaces:
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 throughConsole, 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 MavenLog— the one channel a piped IDE console renders correctly and in order with[INFO]output — and input is read fromSystem.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 Summary
ConstructorsConstructorDescriptionConsoleIkePrompter(org.apache.maven.api.plugin.Log log, boolean interactive) Creates a prompter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanPrompts for a yes/no confirmation.booleanWhether an interactive input channel is available.Prompts for a free-text line of input.Prompts for a numbered selection from a list.
-
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) caseinteractive- whether Maven is in an interactive context; passfalsefor batch mode (the prompter then declines all prompts)
-
-
Method Details
-
isInteractive
public boolean isInteractive()Description copied from interface:IkePrompterWhether 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:
isInteractivein interfaceIkePrompter- Returns:
- true when prompting is possible
-
prompt
Description copied from interface:IkePrompterPrompts for a free-text line of input.- Specified by:
promptin interfaceIkePrompter- Parameters:
label- the prompt label, including any trailing separator (e.g."Commit message: ")- Returns:
- the entered line (trimmed), or
nullif input was blank, end-of-stream, or not interactive
-
confirm
Description copied from interface:IkePrompterPrompts for a yes/no confirmation.- Specified by:
confirmin interfaceIkePrompter- Parameters:
label- the questiondefaultYes- the answer assumed on blank input or a non-interactive context- Returns:
- the user's choice, or
defaultYesas the default
-
select
Description copied from interface:IkePrompterPrompts for a numbered selection from a list.- Specified by:
selectin interfaceIkePrompter- Parameters:
label- the selection headeroptions- the choices, rendered as a numbered list- Returns:
- the chosen option, or
nullon invalid, blank, or non-interactive input
-