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
//! Input declarations and choice values for action invocation.
//!
//! Use this module when an [`ActionSpec`](crate::spec::ActionSpec) needs values before it can be
//! invoked:
//!
//! - [`ActionInput`] declares the value a UI surface must collect.
//! - [`ActionChoice`] declares one selectable value for [`ActionInput::Choice`].
use crateInputId;
/// Input required before an action can be invoked.
///
/// Inputs describe values the application needs, not how a particular UI should
/// collect them. A command palette might render choices as rows while another
/// surface might render the same input as a menu.
///
/// Variant meanings:
///
/// - [`Text`](Self::Text) collects free-form text.
/// - [`Choice`](Self::Choice) selects one [`ActionChoice`].
/// - [`Bool`](Self::Bool) selects `true` or `false`.
///
/// Use [`id`](Self::id), [`label`](Self::label), [`choices`](Self::choices), and
/// [`as_choice`](Self::as_choice) to inspect an input without matching every variant.
///
/// # Examples
///
/// ```
/// use ratatui_action::id::InputId;
/// use ratatui_action::input::{ActionChoice, ActionInput};
///
/// let input = ActionInput::Choice {
/// id: InputId::new("theme"),
/// label: "Theme".into(),
/// choices: vec![ActionChoice::new("catppuccin", "Catppuccin")],
/// };
///
/// assert_eq!(input.id().as_str(), "theme");
/// assert_eq!(input.label(), "Theme");
/// assert_eq!(input.choices().unwrap()[0].value(), "catppuccin");
/// ```
/// A selectable value for a choice input.
///
/// The `value` is the stable value inserted into
/// [`ActionArgs`](crate::invocation::ActionArgs). The `label` and optional
/// description are presentation text.
///
/// Use [`new`](Self::new) to create a choice, [`with_description`](Self::with_description) to add
/// visible detail, and [`value`](Self::value), [`label`](Self::label), and
/// [`description`](Self::description) to inspect it.
///
/// # Examples
///
/// ```
/// use ratatui_action::input::ActionChoice;
///
/// let choice = ActionChoice::new("github-dark", "GitHub Dark")
/// .with_description("Dark theme based on GitHub syntax colors");
///
/// assert_eq!(choice.value(), "github-dark");
/// assert_eq!(choice.label(), "GitHub Dark");
/// assert_eq!(
/// choice.description(),
/// Some("Dark theme based on GitHub syntax colors")
/// );
/// ```