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