Java terminal components with a Diva elegance
- Simplicity β This is not a framework for full-featured TUI rather than basic components for command-based CLI applications.
- Sleek, Rich Styling β ANSI colors, bold prompts, and smooth animations.
- JLine3-Powered β Sharp and precise.
- Ready to use β Jump in straight to terminal components.
try (var presenter = ConsoleTerminalPresenter.standard()) {
var actions = List.of("first", "second", "third", "fourth", "fifth");
var choice = presenter.stringChoice("What action you want to perform?", actions);
var confirmed = presenter.confirm(choice + " - are you sure?");
if (confirmed) {
presenter.successMessage("Action completed");
}
}Add the essence of DivaTerm to your project:
dependencies {
implementation("io.github.klakpin:divaterm:0.0.6")
}<dependency>
<groupId>io.github.klakpin</groupId>
<artifactId>divaterm</artifactId>
<version>0.0.6</version>
</dependency>Awaken your terminal's power with the high-level presenter and use it directly:
var presenter = ConsoleTerminalPresenter.standard();
presenter.successMessage("Action completed");- plain
- success
- error
- bracket
- error bracket
- simple waiting
- waiting with details
var waitingFuture = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
presenter.waitWhile("Waiting 5 seconds", waitingFuture);- simple prompt
- prompt with default value
- string single choice
- string multichoice
- choice builder
var dessertsChoices = /* init choices */
var selectedChoice = presenter.choice(cb ->
cb.withQuestion("What dessert you want to have today?")
.withOptions(new ArrayList<>(dessertsChoices))
.withMaxDisplayResults(5)
.withFilteringEnabled(true)
.withFilterSimilarityCutoff(0.7)
);var dessertsChoices = /* init choices */
var selectedChoice = presenter.multiChoice(cb ->
cb.withQuestion("What dessert you want to have today?")
.withOptions(new ArrayList<>(dessertsChoices))
.withMaxDisplayResults(5)
.withMaxSelectResults(3)
.withFilteringEnabled(true)
);presenter.confirm();DivaTerm offers three elegant ways to bring terminal magic to your Java applications:
- High-Level Presenter (Recommended)
The simplest way to create beautiful terminal interfaces with minimal code:var presenter = ConsoleTerminalPresenter.standard();
Note: the high-level presenter assumes that application is run in interactive terminal with rich colors.
-
Terminal Components Factory
For more control, create individual components through our factory:// JLine terminal instance var terminal = new JlineTerminalFactory().buildTerminal(); // Color palette for elements var colorPalette = new DefaultTerminalColorPalette(Collections.emptyMap(), true); // Executor for drawing async updates, like in a waiting component var drawingExecutor = Executors.newSingleThreadScheduledExecutor(); // Build components factory var factory = new TerminalComponentFactory(terminal, drawingExecutor, colorPalette); // Use factory to show the element factory.buildConfirm().confirm(confirmationText);
Or get the components factory from the presenter
var presenter = ConsoleTerminalPresenter.standard(); vat factory = presenter.getComponentsFactory();
-
Direct Components Usage
For maximum flexibility, use components directly. Do not call the same component twice, most of them are single-use.// JLine terminal instance var terminal = new JlineTerminalFactory().buildTerminal(); // Color palette for elements var colorPalette = new DefaultTerminalColorPalette(Collections.emptyMap(), true); var messageComponent = new TerminalMessage(terminal, colorPalette); messageComponent.printMessage(message, ColorFeature.error);
This project thrives on elegant code and sharp fangs (bug reports).
- Fork β
git cloneβ Put your magic (code). - Submit a PR
For Micronaut/GraalVM warriors:
π Chevalier: The Elite CLI Runtime
MIT β "Free as the night wind."
This project uses:
- JLine3 (BSD 3-Clause).
- Apache Commons (Apache 2.0)
"Sing, my Diva."



