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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user