Add Help component for CLI usage and input validation support

- Introduced `Help` class for generating CLI help/usage blocks with options, descriptions, and customizable formatting.
- Enhanced `Prompt` and `PromptBuilder` with validation capabilities using predicates and retry messages.
- Added terminal control methods `clearScreen` and `cursorTo` with ANSI support.
- Updated examples and documentation (`Examples.md`, `Components.md`) to showcase the new features.
- Extended `Examples` class with a `helpBlock` method for demonstrating the `Help` usage.
This commit is contained in:
!verity
2026-03-14 12:00:31 +01:00
parent 21256dc2dd
commit 4b44c1d155
8 changed files with 232 additions and 12 deletions

View File

@@ -24,6 +24,7 @@ public final class Examples {
columns();
steps();
breadcrumb();
helpBlock();
log();
logWithMinLevel();
diff();
@@ -128,6 +129,17 @@ public final class Examples {
System.out.println();
}
static void helpBlock() {
Terminal.print("=== Help (CLI usage) ===").color(Color.CYAN).bold().println();
Terminal.help()
.title("Options")
.option("-v, --verbose", "Enable verbose output")
.option("-h, --help", "Show this help")
.option("--file <path>", "Input file path")
.print(System.out);
System.out.println();
}
static void log() {
Terminal.print("=== Log ===").color(Color.CYAN).bold().println();
Terminal.log()