1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
//! Interactive prompts — clack/prompts-style.
//!
//! # Hello, prompt
//!
//! ```no_run
//! use cli_ui::prompt::{intro, outro, text, confirm, OnCancel};
//!
//! fn main() {
//! intro("Set up a new project");
//!
//! let name = text("What's your name?")
//! .placeholder("Anya")
//! .run()
//! .or_cancel("Cancelled.");
//!
//! let public = confirm("Make it public?")
//! .default(true)
//! .run()
//! .or_cancel("Cancelled.");
//!
//! outro(format!("Hello {name}! profile is {}.",
//! if public { "public" } else { "private" }));
//! }
//! ```
//!
//! # The mental model
//!
//! Every prompt is one of three things:
//!
//! 1. **A builder** — `text("…")`, `select("…")`, etc. Chain `.placeholder()`,
//! `.default()`, `.validate()`, `.option()` etc. Always finish with `.run()`.
//! 2. **A frame helper** — [`intro`], [`outro`], [`note`], [`cancel`],
//! [`boxed::boxed`]. They print a single framed line/block and return
//! immediately. Use them to surround your prompt flow.
//! 3. **A long-running task display** — [`spinner`](fn@spinner), [`progress`],
//! [`tasks`](fn@tasks), [`task_log`](fn@task_log). These run in the foreground
//! while non-prompt work happens.
//!
//! Everything renders to **stderr** so your prompts don't pollute pipes.
//!
//! # The four categories at a glance
//!
//! ## Question prompts
//!
//! | Prompt | Picks |
//! |-------------------|--------------------------------------|
//! | [`text`](fn@text) | A line of text |
//! | [`secret`] | A masked line (password, API key) |
//! | [`multiline`](fn@multiline) | Several lines |
//! | [`confirm`](fn@confirm) | Yes / No |
//! | [`select`](fn@select) | One option from a list |
//! | [`multiselect`](fn@multiselect) | Many options from a list |
//! | [`groupmultiselect`](fn@groupmultiselect) | Many options from grouped lists |
//! | [`autocomplete`](fn@autocomplete) | One option, filtered by typing |
//! | [`select_key`](fn@select_key) | One option by single keypress |
//! | [`date::date`] | A `yyyy-mm-dd` date |
//! | [`path::path`] | A filesystem path with completion |
//!
//! ## Framing
//!
//! [`intro`] / [`outro`] / [`note`] / [`cancel`] / [`boxed::boxed`] /
//! [`log`] / [`stream`].
//!
//! ## Live work
//!
//! [`spinner`](fn@spinner) / [`progress`] / [`tasks`](fn@tasks) / [`task_log`](fn@task_log).
//!
//! ## Composition
//!
//! [`group::group`] runs many prompts sequentially and collects their answers.
//!
//! # Validation
//!
//! Validators are promoted to the prompt root so they import like any
//! other constructor:
//!
//! ```no_run
//! use cli_ui::prompt::{text, min_chars, has_upper, has_digit};
//!
//! let pw = text("Password")
//! .rule(min_chars(12).and(has_upper()).and(has_digit()))
//! .run();
//! ```
//!
//! # Customisation
//!
//! Theme everything in one call via [`settings::update_colors`]:
//!
//! ```
//! cli_ui::prompt::settings::update_colors(|c| {
//! c.accent = anstyle::Style::new()
//! .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Magenta)))
//! .bold();
//! });
//! ```
//!
//! # Cancellation
//!
//! When the user hits Ctrl-C or Esc, `.run()` returns
//! `Err(PromptError::Interrupted)`. The [`OnCancel`] extension trait turns
//! that into a clean exit:
//!
//! ```no_run
//! use cli_ui::prompt::{text, OnCancel};
//! let name = text("Your name").run().or_cancel("Aborted — see you next time.");
//! ```
//!
//! # Extending
//!
//! Implement [`core::Prompt`] to ship your own prompt — see the existing
//! prompts in this module for templates. The runner handles raw mode,
//! cleanup, validation transitions, and the answered redraw for you.
//!
//! # One-line import
//!
//! For quick scripts and examples, glob-import the prelude:
//!
//! ```
//! use cli_ui::prompt::prelude::*;
//! ```
pub use ;
pub use ;
pub use confirm;
pub use ;
pub use group;
pub use ;
pub use multiline;
pub use ;
pub use path;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// ── Promoted from `validate::*` ───────────────────────────────────────────────
//
// Every common rule and the `Validator` type sit at the prompt root so users
// can compose without the `validate::` prefix:
//
// use cli_ui::prompt::{text, min_chars, has_upper};
// text("pw").rule(min_chars(8).and(has_upper())).run()?;
//
// The full `validate` module is still re-exported for users who want every
// helper at once.
pub use ;
// ── Promoted from `settings::*` ──────────────────────────────────────────────
//
// The most common settings ops — colour overrides — at the prompt root so
// users can theme without an extra module path:
//
// use cli_ui::prompt::update_colors;
// update_colors(|c| c.accent = magenta_bold);
pub use ;
/// Glob-importable shortcut for the most common entry points.
///
/// ```
/// use cli_ui::prompt::prelude::*;
/// ```
///
/// Re-exports every prompt constructor, the frame helpers (`intro`, `outro`,
/// `note`, `cancel`), `OnCancel`, the validator rules library, and the
/// colour theme ops. Designed for quick scripts; production code can stick
/// with the explicit imports.
// ── Frame helpers (clack-style) ───────────────────────────────────────────────
/// Print `┌ message` — opens a connected prompt session.
/// Print `└ message` — closes a prompt session.
/// Print a framed informational note between prompts.
/// Print `■ message` — used after a prompt was cancelled / interrupted.