Console implementation of the GuiInteraction library.
This module provides console-based (text mode) interaction capabilities. It's designed for headless environments, CI/CD pipelines, and terminal-based applications.
- JDK 21+ (any distribution)
- No GUI required (headless compatible)
- Text-based prompts for user input
- File path input via console
- Table output using Matrix text formatting
- HTML content displayed as plain text (via Jsoup)
- System clipboard access (when not running headless)
dependencies {
implementation 'se.alipsa.gi:gi-console:0.3.0'
}<dependency>
<groupId>se.alipsa.gi</groupId>
<artifactId>gi-console</artifactId>
<version>0.3.0</version>
</dependency>@Grab(group:'se.alipsa.gi', module:'gi-console', version:'0.3.0')
import se.alipsa.gi.console.InOut
def io = new InOut()import se.alipsa.gi.console.InOut
def io = new InOut()
// User prompts (text input)
def name = io.prompt("Enter your name: ")
// File selection (user types path)
def file = io.chooseFile("Open", ".", "Enter file path")
// Display table (outputs formatted text)
io.view([
["Name", "Age"],
["Alice", 30],
["Bob", 25]
], "Users")
// Display HTML (outputs plain text)
io.view("<h1>Hello</h1><p>Welcome!</p>", "Greeting")
// Output: Greeting: Hello Welcome!A fat JAR (with all dependencies bundled) is available:
dependencies {
implementation 'se.alipsa.gi:gi-console:0.3.0:fatjar'
}- Clipboard: Clipboard access is unavailable in headless environments; clipboard methods log the issue and return
nullor no-op. - Password Input: Requires
System.console()to be available. Returnsnullin IDEs and some CI environments where console is unavailable. - Charts/Images:
display(Chart)anddisplay(File)for images print a message instead of showing graphics - Swing Components:
display(JComponent)is not supported - File Choosers: User manually types file paths instead of browsing
The password prompt requires a system console:
def password = io.promptPassword("Login", "Enter password")
if (password == null) {
println("Console not available - cannot read password")
}To ensure console availability:
- Run from a terminal (not IDE "Run" button)
- Use
java -jar app.jarfrom command line
- Jsoup - HTML parsing and text extraction
See the API Guide for detailed usage examples.
MIT License - see LICENSE