|
1 | 1 | # @reliverse/prompts
|
2 | 2 |
|
3 |
| -> **The CLI prompt library you didn’t realize you’ve been desperate for.** |
| 3 | +> **A modern CLI prompt library. Fast, type-safe, and built to last.** |
4 | 4 |
|
5 |
| -[Docs](https://docs.reliverse.org/reliverse/prompts/) | [NPM](https://www.npmjs.com/package/@reliverse/prompts) | [JSR](https://jsr.io/@reliverse/prompts) | [GitHub](https://github.com/reliverse/prompts) | [Discord](https://discord.gg/3GawfWfAPe) |
| 5 | +[](https://npmjs.com/package/@reliverse/prompts) |
| 6 | +[](#license) |
6 | 7 |
|
7 |
| -It’s blazing-fast, type-safe, and has built-in crash resilience—so your command-line app can look slick without bursting into flames. Forget boilerplate-heavy setups—this library makes CLI development smooth and effortless. |
| 8 | +**Quick Links:** |
8 | 9 |
|
9 |
| -## Rapid-Fire Overview |
| 10 | +- **[Docs](https://docs.reliverse.org/reliverse/prompts)** |
| 11 | +- **[NPM](https://npmjs.com/package/@reliverse/prompts)** |
| 12 | +- **[JSR](https://jsr.io/@reliverse/prompts)** |
| 13 | +- **[GitHub](https://github.com/reliverse/prompts)** |
| 14 | +- **[Discord](https://discord.gg/3GawfWfAPe)** |
10 | 15 |
|
11 |
| -<div align="left"> |
12 |
| - <a href="https://npmjs.org/package/@reliverse/prompts"><img src="https://img.shields.io/npm/v/@reliverse/prompts.svg" alt="version" /></a> |
13 |
| - <a href="https://npmjs.org/package/@reliverse/prompts"><img src="https://img.shields.io/npm/dm/@reliverse/prompts.svg" alt="downloads" /></a> |
14 |
| -</div> |
| 16 | +## Overview |
15 | 17 |
|
16 |
| -## Install in 3.2 Seconds |
| 18 | +`@reliverse/prompts` is a **type-safe**, high-performance library for building modern CLI applications. It’s designed to help you focus on creating **great user experiences**, not juggling repetitive CLI logic. |
| 19 | + |
| 20 | +Use `@reliverse/prompts` for everything from quick scripts to full-featured, production-grade tools. With minimal boilerplate, robust error handling, and built-in accessibility features, you’ll be shipping delightful CLI workflows in no time. |
| 21 | + |
| 22 | +## Key Features |
| 23 | + |
| 24 | +- **TypeScript-first** |
| 25 | + Get robust type definitions and IntelliSense for a smoother development experience. |
| 26 | +- **Flexible Prompt Types** |
| 27 | +Includes logger, input (text, password), confirm, select, multiselect, toggle, number, spinner, and more. |
| 28 | +- **Schema-Driven Validation** |
| 29 | + Native compatibility with TypeBox, Zod, or any custom validation strategy. |
| 30 | +- **Accessible & Adaptive** |
| 31 | + Supports terminal resizing, color contrast preferences, and meets WCAG AA standards. |
| 32 | +- **Crash-Resistant** |
| 33 | + Gracefully handles Ctrl+C, unexpected exits, and other edge cases without breaking. |
| 34 | + |
| 35 | +## Installation |
17 | 36 |
|
18 | 37 | ```bash
|
19 | 38 | bun add @reliverse/prompts
|
20 |
| -# Or npm/pnpm/yarn if that’s your style |
21 |
| -# (deno and full jsr support soon™) |
| 39 | +# Or use npm, pnpm, yarn |
22 | 40 | ```
|
23 | 41 |
|
24 |
| -> **Pro Tip**: Make sure you have [Bun](https://bun.sh), [Node.js](https://nodejs.org), and [Git](https://git-scm.com/downloads) installed. |
| 42 | +> **Tip:** Make sure [Bun](https://bun.sh), [Node.js](https://nodejs.org), and [Git](https://git-scm.com/downloads) are installed before proceeding. |
25 | 43 |
|
26 |
| -## The 3-Second Pitch |
| 44 | +## Why Reliverse Prompts? |
27 | 45 |
|
28 |
| -> This thing is **blazing fast**, **type-safe**, and basically a bulletproof vest for your CLI. |
29 |
| -> No more spaghetti prompt code. Just shiny, stable, next-gen developer bliss. |
| 46 | +Unlike Inquirer, Clack, or other prompt libraries, `@reliverse/prompts` centers on **developer experience**: |
30 | 47 |
|
31 |
| -### *“But why not stick with Inquirer or Clack?”* |
| 48 | +- **Enhanced Runtime Typing** – for fewer runtime errors and better IDE hints. |
| 49 | +- **Built-in Error Handling** – robust crash prevention right out of the box. |
| 50 | +- **Customizable Design & Theming** – tailor the look and feel to match your brand. |
| 51 | +- **Zero Guesswork with TypeScript** – strict typing means fewer surprises. |
| 52 | +- **Built-in Argument Parsing** – do more with less code by leveraging built-in typecasting and validation. |
32 | 53 |
|
33 |
| -1. Better typed validation, bigger ASCII art, more interactive goodies, and next-level color theming. |
34 |
| -2. Because you deserve better than “just good enough.” |
| 54 | +Benchmarks confirm that `@reliverse/prompts` is one of the fastest and easiest libraries to work with. |
| 55 | +[See the feature comparison →](https://docs.reliverse.org/reliverse/prompts/#prompts-library-comparison) |
35 | 56 |
|
36 |
| -## Key Selling Points |
37 |
| - |
38 |
| -- **TypeScript-first**: So your TypeScript dev heart can flutter in peace. Enjoy IntelliSense and zero guesswork. |
39 |
| -- **Flexible Prompt Types**: Text, confirm, select, multiselect, password, number, spinner, toggle, and many more… you do you. |
40 |
| -- **Schema-driven Validations**: Easily integrates with TypeBox, Zod, or your own thing. No more “hope it works” solutions. |
41 |
| -- **Accessibility**: Terminal-size awareness, WCAG AA color contrast, the whole enchilada. |
42 |
| -- **Crash-safe**: Ctrl+C or random cosmic rays? It shrugs them off. |
| 57 | +## Playground Mode |
43 | 58 |
|
44 |
| -## Why @reliverse/prompts? |
| 59 | +Try out examples locally to see how everything works in practice: |
45 | 60 |
|
46 |
| -Consider it your brand-new sports car, while your old CLI prompt library was a rusty lawnmower. Also, it’s a feature-packed replacement for Inquirer, Enquirer, Clack, Terkelg, Terminal-Kit, and a bunch more. |
| 61 | +```bash |
| 62 | +git clone https://github.com/reliverse/prompts.git |
| 63 | +cd prompts |
| 64 | +bun i |
| 65 | +bun dev |
| 66 | +``` |
47 | 67 |
|
48 |
| -[**Go deeper in the docs →**](https://docs.reliverse.org/reliverse/prompts/) |
| 68 | +Then open **`examples/launcher.ts`** to explore various interactive demos or experiment with different prompt types. |
49 | 69 |
|
50 |
| -### Straight-Up GOAT Features |
| 70 | + |
51 | 71 |
|
52 |
| -- **Full Cross-Platform ESM**: Seamlessly works with the Node.js and Bun environments. |
53 |
| -- **Extensible UI**: Because color, typography, animations, and more matter to your terminal fashion sense. |
54 |
| -- **Built for DX**: Minimal dependencies, clean API, full validation baked in, and more. |
55 |
| -- **Mono Component**: Perfect for rapid prototyping. Or if you’re feeling lazy. |
| 72 | +## Example Usage |
56 | 73 |
|
57 |
| -## Speedrun Example |
| 74 | +Here’s a quick look at how you might use `@reliverse/prompts` in your CLI: |
58 | 75 |
|
59 | 76 | ```ts
|
60 |
| -import { inputPrompt } from "@reliverse/prompts"; |
| 77 | +import { |
| 78 | + startPrompt, // Initializes the CLI session (clears the console, sets a custom title, etc.) |
| 79 | + inputPrompt // Fetches user input with validation and styled UI |
| 80 | +} from "@reliverse/prompts"; |
61 | 81 |
|
62 | 82 | await startPrompt({
|
63 | 83 | clearConsole: true,
|
64 | 84 | titleColor: "inverse",
|
65 | 85 | packageName: "@reliverse/cli",
|
66 | 86 | packageVersion: "1.0.0",
|
67 |
| - terminalSizeOptions: { |
68 |
| - minWidth: 100, |
69 |
| - minHeight: 16, |
70 |
| - // 🗴 Oops! Terminal width is too small. Expected >100 | Current: 97 |
71 |
| - }, |
72 | 87 | });
|
73 | 88 |
|
74 | 89 | const username = await inputPrompt({
|
75 | 90 | id: "username",
|
76 |
| - title: "Welcome to @reliverse/prompts Demo!", |
| 91 | + title: "Welcome!", |
77 | 92 | content: "What's your name?",
|
78 | 93 | });
|
79 | 94 |
|
80 | 95 | console.log(`Hey there, ${username}!`);
|
81 | 96 | ```
|
82 | 97 |
|
83 |
| -## Task Management |
84 |
| - |
85 |
| -The library provides a powerful task management system with built-in verification steps, spinners, and error handling: |
86 |
| - |
87 |
| -- **Spinner and progress bars that actually move**: Progress tracking with current/total counts and status messages |
88 |
| -- **Task priorities (because some stuff is more important)**: Critical, high, normal, low |
89 |
| -- **Built-in stats, error handling, and cancellation**: Task timing and statistics, built-in error handling and cancellation support |
90 |
| -- **Customizable spinners to keep your eyes happy**: Customizable spinners and progress indicators |
91 |
| -- **Nested subtasks and task groups**: Group tasks and subtasks for better organization |
92 |
| -- **Automatic verification steps with customizable delays** |
93 |
| -- **Simple error handling with proper formatting** |
94 |
| -- **Progress tracking for long-running operations** |
95 |
| -- **Custom validation and business logic support** |
96 |
| - |
97 |
| -Visit [docs](https://docs.reliverse.org/reliverse/prompts/#task-management) to learn more and see examples. |
98 |
| - |
99 |
| -## Playground Mode |
100 |
| - |
101 |
| -```bash |
102 |
| -git clone https://github.com/reliverse/prompts.git |
103 |
| -cd prompts |
104 |
| -bun i |
105 |
| -bun dev |
106 |
| -``` |
107 |
| - |
108 |
| -Check out `examples/launcher.ts` for a smorgasbord of demos (including a quiz). Who says CLIs can’t be fun? |
109 |
| - |
110 |
| -## Examples to Copy-Paste |
111 |
| - |
112 |
| -1. **1-main.ts**: A powerhouse CLI example with all the trimmings, with advanced styling and all prompts. |
113 |
| -2. **2-mono.ts**: A single `prompt()` for multiple components—perfect for CLI where performance doesn't matter. |
114 |
| -3. **3-simple.ts**: Less code, more speed. |
115 |
| -4. **4-args-a.ts** + **5-args-b.ts**: Turn sub-commands into a more headless experience. |
116 |
| - |
117 |
| -## Custom Config FTW |
118 |
| - |
119 |
| -You don’t want a one-size-fits-all library. We got you: |
120 |
| - |
121 |
| -```ts |
122 |
| -const basicConfig = { |
123 |
| - titleColor: "cyanBright", |
124 |
| - titleTypography: "bold", |
125 |
| - borderColor: "dim", |
126 |
| -} satisfies PromptOptions; |
127 |
| - |
128 |
| -const extendedConfig = { |
129 |
| - ...basicConfig, |
130 |
| - contentTypography: "italic", |
131 |
| - contentColor: "dim", |
132 |
| -} satisfies PromptOptions; |
133 |
| - |
134 |
| -const username = await inputPrompt({ |
135 |
| - id: "username", |
136 |
| - title: "Testing out our fancy library!", |
137 |
| - content: "What's your username?", |
138 |
| - ...extendedConfig, |
139 |
| -}); |
140 |
| -``` |
141 |
| - |
142 |
| -## Mono Component: One Import to Rule Them All |
143 |
| - |
144 |
| -If you’re lazy (like the rest of us), in a hurry, or just want everything jammed together, the Mono Component wraps up all prompt types in a single import. |
145 |
| - |
146 |
| -```ts |
147 |
| -export const IDs = { |
148 |
| - start: "start", |
149 |
| - username: "username", |
150 |
| - // ... |
151 |
| -}; |
152 |
| -``` |
153 |
| - |
154 |
| -## Comparison Table |
155 |
| - |
156 |
| -We’re not shy. We lined up **@reliverse/prompts** against Inquirer, Clack, Terminal-Kit, etc. Our goal? **Turn every feature dot green**. [**Check out the epic chart**](https://docs.reliverse.org/reliverse/prompts/#prompts-library-comparison) |
157 |
| - |
158 |
| -## Arguments Support |
159 |
| - |
160 |
| -You can’t build an amazing CLI without argument parsing. We’ve got a built-in fast parser that typecasts your things automatically. |
161 |
| - |
162 |
| -## Wrap It Up |
| 98 | +## Contributing |
163 | 99 |
|
164 |
| -@reliverse/prompts is more than just pretty and fast prompts—it’s a full-blown CLI builder with customizable designs and robust typing. It’s built to slot seamlessly into Reliverse’s ecosystem, but even if you’re rolling your own thing, you’ll appreciate the minimal boilerplate and fancy visuals. |
165 |
| - |
166 |
| -- **CLI builder** with style & resilience |
167 |
| -- **Customizable** design and color theming |
168 |
| -- **Zero guesswork** with TypeScript integrations |
169 |
| -- **Minimal boilerplate** with maximum results |
170 |
| - |
171 |
| -## More Goodies |
172 |
| - |
173 |
| -- [**Reliverse Docs**](https://docs.reliverse.org/reliverse/prompts/) |
174 |
| - |
175 |
| -## Special Thanks |
176 |
| - |
177 |
| -**@inquirer/prompts**, **@terkelg/prompts**, **@clack/prompts**, **@unjs/citty**, and many more other open-source legends. You built the shoulders we stand on. |
| 100 | +Contributions are always welcome! Open a pull request or start a discussion on [GitHub](https://github.com/reliverse/prompts) if you’d like to help. By the way, this project emphasizes functional programming approaches, avoiding traditional OOP classes. |
178 | 101 |
|
179 | 102 | ## License
|
180 | 103 |
|
181 |
| -**MIT** © [Nazarii Korniienko](https://github.com/reliverse/prompts) |
182 |
| - |
183 |
| -## Screenshot Brag |
| 104 | +**MIT License** © [Nazarii Korniienko](https://github.com/reliverse/prompts) |
184 | 105 |
|
185 |
| -[](./examples/main.png) |
| 106 | +Feel free to modify and redistribute under the terms of the MIT license. See the [LICENSE](LICENSE) file for more details. |
186 | 107 |
|
187 |
| -> **Stop reading. Start coding.** |
188 |
| -> |
189 |
| -> If you’re serious about CLIs—don’t just build—**Reliverse it** with `@reliverse/prompts`. |
| 108 | +Thanks for checking out `@reliverse/prompts`. If you have any questions, join our [Discord community](https://discord.gg/3GawfWfAPe) or file an issue on GitHub. We look forward to seeing what you build! |
0 commit comments