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

@@ -26,11 +26,12 @@ Overview of what terminal-ui provides. All entry points are on `Terminal.*`.
| API | Description |
|-----|-------------|
| `Terminal.prompt(String)` | Text input (`.ask()`, `.masked().ask()`) |
| `Terminal.prompt(String)` | Text input (`.ask()`, `.masked().ask()`, `.validate(Predicate).retryMessage(String)`) |
| `Terminal.confirm(String)` | Y/n confirmation |
| `Terminal.menu()` | Numbered menu (`.option()`, `.select()`) |
| `Terminal.selectList()` | List with arrow keys + Enter |
| `Terminal.pager()` | Paged output (Enter/arrows/q) |
| `Terminal.help()` | CLI usage block (`.option(opt, desc)`, `.title()`) |
## Live / progress
@@ -50,6 +51,13 @@ Overview of what terminal-ui provides. All entry points are on `Terminal.*`.
| `Terminal.heatmap()` | Heatmap |
| `Terminal.chart()` | Charts |
## Terminal control (ANSI)
| API | Description |
|-----|-------------|
| `Terminal.clearScreen()` | Clear entire screen |
| `Terminal.cursorTo(row, col)` | Move cursor (1-based) |
## Other
| API | Description |