1use crate::CliOverridesPatch;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct PluginCommandRequest {
6 pub overrides: CliOverridesPatch,
8}
9
10impl PluginCommandRequest {
11 pub fn new() -> Self {
12 Self {
13 overrides: CliOverridesPatch::default(),
14 }
15 }
16
17 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
19 self.overrides = overrides;
20 self
21 }
22}
23
24impl Default for PluginCommandRequest {
25 fn default() -> Self {
26 Self::new()
27 }
28}
29
30#[derive(Clone, Debug, Eq, PartialEq)]
32pub struct PluginHelpRequest {
33 pub command: Vec<String>,
35 pub overrides: CliOverridesPatch,
37}
38
39impl PluginHelpRequest {
40 pub fn new() -> Self {
41 Self {
42 command: Vec::new(),
43 overrides: CliOverridesPatch::default(),
44 }
45 }
46
47 pub fn command(mut self, command: impl IntoIterator<Item = impl Into<String>>) -> Self {
49 self.command = command.into_iter().map(Into::into).collect();
50 self
51 }
52
53 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
55 self.overrides = overrides;
56 self
57 }
58}
59
60impl Default for PluginHelpRequest {
61 fn default() -> Self {
62 Self::new()
63 }
64}
65
66#[derive(Clone, Debug, Eq, PartialEq)]
68pub struct PluginMarketplaceCommandRequest {
69 pub overrides: CliOverridesPatch,
71}
72
73impl PluginMarketplaceCommandRequest {
74 pub fn new() -> Self {
75 Self {
76 overrides: CliOverridesPatch::default(),
77 }
78 }
79
80 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
82 self.overrides = overrides;
83 self
84 }
85}
86
87impl Default for PluginMarketplaceCommandRequest {
88 fn default() -> Self {
89 Self::new()
90 }
91}
92
93#[derive(Clone, Debug, Eq, PartialEq)]
95pub struct PluginMarketplaceHelpRequest {
96 pub command: Vec<String>,
98 pub overrides: CliOverridesPatch,
100}
101
102impl PluginMarketplaceHelpRequest {
103 pub fn new() -> Self {
104 Self {
105 command: Vec::new(),
106 overrides: CliOverridesPatch::default(),
107 }
108 }
109
110 pub fn command(mut self, command: impl IntoIterator<Item = impl Into<String>>) -> Self {
112 self.command = command.into_iter().map(Into::into).collect();
113 self
114 }
115
116 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
118 self.overrides = overrides;
119 self
120 }
121}
122
123impl Default for PluginMarketplaceHelpRequest {
124 fn default() -> Self {
125 Self::new()
126 }
127}
128
129#[derive(Clone, Debug, Eq, PartialEq)]
131pub struct PluginMarketplaceAddRequest {
132 pub source: String,
134 pub source_ref: Option<String>,
136 pub sparse_path: Option<String>,
138 pub overrides: CliOverridesPatch,
140}
141
142impl PluginMarketplaceAddRequest {
143 pub fn new(source: impl Into<String>) -> Self {
144 Self {
145 source: source.into(),
146 source_ref: None,
147 sparse_path: None,
148 overrides: CliOverridesPatch::default(),
149 }
150 }
151
152 pub fn source_ref(mut self, source_ref: impl Into<String>) -> Self {
154 let source_ref = source_ref.into();
155 self.source_ref = (!source_ref.trim().is_empty()).then_some(source_ref);
156 self
157 }
158
159 pub fn sparse_path(mut self, sparse_path: impl Into<String>) -> Self {
161 let sparse_path = sparse_path.into();
162 self.sparse_path = (!sparse_path.trim().is_empty()).then_some(sparse_path);
163 self
164 }
165
166 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
168 self.overrides = overrides;
169 self
170 }
171}
172
173#[derive(Clone, Debug, Eq, PartialEq)]
175pub struct PluginMarketplaceRemoveRequest {
176 pub marketplace_name: String,
178 pub overrides: CliOverridesPatch,
180}
181
182impl PluginMarketplaceRemoveRequest {
183 pub fn new(marketplace_name: impl Into<String>) -> Self {
184 Self {
185 marketplace_name: marketplace_name.into(),
186 overrides: CliOverridesPatch::default(),
187 }
188 }
189
190 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
192 self.overrides = overrides;
193 self
194 }
195}
196
197#[derive(Clone, Debug, Eq, PartialEq)]
199pub struct PluginMarketplaceUpgradeRequest {
200 pub marketplace_name: Option<String>,
202 pub overrides: CliOverridesPatch,
204}
205
206impl PluginMarketplaceUpgradeRequest {
207 pub fn new() -> Self {
208 Self {
209 marketplace_name: None,
210 overrides: CliOverridesPatch::default(),
211 }
212 }
213
214 pub fn marketplace_name(mut self, marketplace_name: impl Into<String>) -> Self {
216 let marketplace_name = marketplace_name.into();
217 self.marketplace_name = (!marketplace_name.trim().is_empty()).then_some(marketplace_name);
218 self
219 }
220
221 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
223 self.overrides = overrides;
224 self
225 }
226}
227
228impl Default for PluginMarketplaceUpgradeRequest {
229 fn default() -> Self {
230 Self::new()
231 }
232}