1pub mod ansi;
2pub mod cell;
3pub mod colors;
4pub mod command;
5pub mod editor;
6pub mod element;
7pub mod format;
8pub mod hstack;
9pub mod io;
10pub mod label;
11pub mod spinner;
12pub mod table;
13pub mod textarea;
14pub mod vstack;
15
16use std::fmt;
17use std::io::IsTerminal;
18
19pub use ansi::Color;
20pub use ansi::{paint, Filled, Paint, Style, TerminalFile};
21pub use editor::Editor;
22pub use element::{Constraint, Element, Line, Size};
23pub use hstack::HStack;
24pub use inquire::ui::Styled;
25pub use io::*;
26pub use label::{label, Label};
27pub use spinner::{spinner, spinner_to, Spinner};
28pub use table::{Table, TableOptions};
29pub use textarea::{textarea, TextArea};
30pub use vstack::{VStack, VStackOptions};
31
32#[derive(Debug, PartialEq, Eq, Copy, Clone, Default)]
33pub enum Interactive {
34 Yes,
35 #[default]
36 No,
37}
38
39impl Interactive {
40 pub fn new(term: impl IsTerminal) -> Self {
41 Self::from(term.is_terminal())
42 }
43
44 pub fn yes(&self) -> bool {
45 (*self).into()
46 }
47
48 pub fn no(&self) -> bool {
49 !self.yes()
50 }
51
52 pub fn confirm(&self, prompt: impl fmt::Display) -> bool {
53 if self.yes() {
54 confirm(prompt)
55 } else {
56 true
57 }
58 }
59}
60
61impl From<Interactive> for bool {
62 fn from(c: Interactive) -> Self {
63 match c {
64 Interactive::Yes => true,
65 Interactive::No => false,
66 }
67 }
68}
69
70impl From<bool> for Interactive {
71 fn from(b: bool) -> Self {
72 if b {
73 Interactive::Yes
74 } else {
75 Interactive::No
76 }
77 }
78}
79
80pub fn style<T>(item: T) -> Paint<T> {
81 paint(item)
82}