1use argh::FromArgs;
6use component_debug::cli::{GraphFilter, GraphOrientation, ListFilter};
7use component_debug::config::RawConfigEntry;
8use component_debug::explore::DashNamespaceLayout;
9use fuchsia_url::AbsoluteComponentUrl;
10use moniker::Moniker;
11
12#[derive(FromArgs, PartialEq, Debug)]
13#[argh(
14 name = "component",
15 description = "Discover and manage components. Functionally equivalent to `ffx component`."
16)]
17pub struct ComponentArgs {
18 #[argh(subcommand)]
19 pub subcommand: ComponentSubcommand,
20}
21
22#[derive(FromArgs, PartialEq, Debug)]
23#[argh(subcommand)]
24pub enum ComponentSubcommand {
25 Capability(CapabilityArgs),
26 List(ListArgs),
27 Graph(GraphArgs),
28 Show(ShowArgs),
29 Create(CreateArgs),
30 Destroy(DestroyArgs),
31 Resolve(ResolveArgs),
32 Run(RunArgs),
33 Start(StartArgs),
34 Stop(StopArgs),
35 Reload(ReloadArgs),
36 Doctor(DoctorArgs),
37 Copy(CopyArgs),
38 Route(RouteArgs),
39 Storage(StorageArgs),
40 Collection(CollectionArgs),
41 Explore(ExploreArgs),
42 Config(ConfigArgs),
43}
44
45#[derive(FromArgs, PartialEq, Debug)]
46#[argh(subcommand, name = "show", description = "Same as `ffx component show`")]
47pub struct ShowArgs {
48 #[argh(positional)]
49 pub query: String,
51}
52
53#[derive(FromArgs, Debug, PartialEq)]
54#[argh(subcommand, name = "create", description = "Same as `ffx component create`")]
55pub struct CreateArgs {
56 #[argh(positional)]
57 pub moniker: Moniker,
58
59 #[argh(positional)]
60 pub url: AbsoluteComponentUrl,
61
62 #[argh(option)]
63 pub config: Vec<RawConfigEntry>,
68}
69
70#[derive(FromArgs, Debug, PartialEq)]
71#[argh(subcommand, name = "resolve", description = "Same as `ffx component resolve`")]
72pub struct ResolveArgs {
73 #[argh(positional)]
74 pub query: String,
76}
77
78#[derive(FromArgs, Debug, PartialEq)]
79#[argh(subcommand, name = "destroy", description = "Same as `ffx component destroy`")]
80pub struct DestroyArgs {
81 #[argh(positional)]
82 pub query: String,
84}
85
86#[derive(FromArgs, Debug, PartialEq)]
87#[argh(subcommand, name = "start", description = "Same as `ffx component start`")]
88pub struct StartArgs {
89 #[argh(positional)]
90 pub query: String,
92}
93
94#[derive(FromArgs, Debug, PartialEq)]
95#[argh(subcommand, name = "stop", description = "Same as `ffx component stop`")]
96pub struct StopArgs {
97 #[argh(positional)]
98 pub query: String,
100}
101
102#[derive(FromArgs, Debug, PartialEq)]
103#[argh(subcommand, name = "reload", description = "Same as `ffx component reload`")]
104pub struct ReloadArgs {
105 #[argh(positional)]
106 pub query: String,
108}
109
110#[derive(FromArgs, Debug, PartialEq)]
111#[argh(subcommand, name = "doctor", description = "Same as `ffx component doctor`")]
112pub struct DoctorArgs {
113 #[argh(positional)]
114 pub query: String,
116}
117
118#[derive(FromArgs, Debug, PartialEq)]
119#[argh(subcommand, name = "capability", description = "Same as `ffx component capability`")]
120pub struct CapabilityArgs {
121 #[argh(positional)]
122 pub capability_name: String,
123}
124
125#[derive(FromArgs, Debug, PartialEq)]
126#[argh(subcommand, name = "list", description = "Same as `ffx component list`")]
127pub struct ListArgs {
128 #[argh(option, long = "only", short = 'o')]
129 pub filter: Option<ListFilter>,
131
132 #[argh(switch, long = "verbose", short = 'v')]
133 pub verbose: bool,
135}
136
137#[derive(FromArgs, Debug, PartialEq)]
138#[argh(subcommand, name = "graph", description = "Same as `ffx component graph`")]
139pub struct GraphArgs {
140 #[argh(option, long = "only", short = 'o')]
141 pub filter: Option<GraphFilter>,
143
144 #[argh(option, long = "orientation", short = 'r', default = "GraphOrientation::TopToBottom")]
145 pub orientation: GraphOrientation,
148}
149
150#[derive(FromArgs, Debug, PartialEq)]
151#[argh(subcommand, name = "run", description = "Same as `ffx component run`")]
152pub struct RunArgs {
153 #[argh(positional)]
154 pub moniker: Moniker,
155
156 #[argh(positional)]
157 pub url: AbsoluteComponentUrl,
158
159 #[argh(switch, short = 'r')]
160 pub recreate: bool,
162
163 #[argh(switch)]
164 pub connect_stdio: bool,
167
168 #[argh(option)]
169 pub config: Vec<RawConfigEntry>,
174}
175
176#[derive(FromArgs, Debug, PartialEq)]
177#[argh(subcommand, name = "route", description = "Same as `ffx component route`")]
178pub struct RouteArgs {
179 #[argh(positional)]
180 pub target: String,
182
183 #[argh(positional)]
184 pub filter: Option<String>,
195}
196
197#[derive(FromArgs, Debug, PartialEq)]
198#[argh(subcommand, name = "copy", description = "Same as `ffx component copy`")]
199pub struct CopyArgs {
200 #[argh(positional)]
201 pub paths: Vec<String>,
202 #[argh(switch, short = 'v')]
204 pub verbose: bool,
205}
206
207#[derive(FromArgs, Debug, PartialEq)]
208#[argh(subcommand, name = "storage", description = "Same as `ffx component storage`")]
209pub struct StorageArgs {
210 #[argh(subcommand)]
211 pub subcommand: StorageSubcommand,
212
213 #[argh(option, default = "String::from(\"/core\")")]
214 pub provider: String,
217
218 #[argh(option, default = "String::from(\"data\")")]
219 pub capability: String,
223}
224
225#[derive(FromArgs, PartialEq, Debug)]
226#[argh(subcommand)]
227pub enum StorageSubcommand {
228 Copy(StorageCopyArgs),
229 Delete(StorageDeleteArgs),
230 List(StorageListArgs),
231 MakeDirectory(StorageMakeDirectoryArgs),
232}
233
234#[derive(FromArgs, PartialEq, Debug)]
235#[argh(subcommand, name = "list", description = "Same as `ffx component storage list`")]
236pub struct StorageListArgs {
237 #[argh(positional)]
238 pub path: String,
239}
240
241#[derive(FromArgs, Debug, PartialEq)]
242#[argh(
243 subcommand,
244 name = "make-directory",
245 description = "Same as `ffx component storage make-directory`"
246)]
247pub struct StorageMakeDirectoryArgs {
248 #[argh(positional)]
249 pub path: String,
250}
251
252#[derive(FromArgs, Debug, PartialEq)]
253#[argh(subcommand, name = "copy", description = "Same as `ffx component storage copy`")]
254pub struct StorageCopyArgs {
255 #[argh(positional)]
256 pub source_path: String,
257
258 #[argh(positional)]
259 pub destination_path: String,
260}
261
262#[derive(FromArgs, Debug, PartialEq)]
263#[argh(subcommand, name = "delete", description = "Same as `ffx component storage delete`")]
264pub struct StorageDeleteArgs {
265 #[argh(positional)]
266 pub path: String,
267}
268
269#[derive(FromArgs, Debug, PartialEq)]
270#[argh(subcommand, name = "collection", description = "Same as `ffx component collection`")]
271pub struct CollectionArgs {
272 #[argh(subcommand)]
273 pub subcommand: CollectionSubcommand,
274}
275
276#[derive(FromArgs, PartialEq, Debug)]
277#[argh(subcommand)]
278pub enum CollectionSubcommand {
279 List(CollectionListArgs),
280 Show(CollectionShowArgs),
281}
282
283#[derive(FromArgs, PartialEq, Debug)]
284#[argh(subcommand, name = "list", description = "Same as `ffx component collection list`")]
285pub struct CollectionListArgs {
286 #[argh(positional)]
287 pub path: String,
288}
289
290#[derive(FromArgs, Debug, PartialEq)]
291#[argh(subcommand, name = "show", description = "Same as `ffx component collection show`")]
292pub struct CollectionShowArgs {
293 #[argh(positional)]
294 pub query: String,
295}
296
297#[derive(FromArgs, Debug, PartialEq)]
298#[argh(subcommand, name = "explore", description = "Same as `ffx component explore`")]
299pub struct ExploreArgs {
300 #[argh(positional)]
301 pub query: String,
303
304 #[argh(option)]
305 pub tools: Vec<String>,
310
311 #[argh(option, short = 'c', long = "command")]
312 pub command: Option<String>,
315
316 #[argh(
317 option,
318 short = 'l',
319 long = "layout",
320 default = "DashNamespaceLayout::NestAllInstanceDirs"
321 )]
322 pub ns_layout: DashNamespaceLayout,
326}
327
328#[derive(FromArgs, Debug, PartialEq)]
329#[argh(subcommand, name = "config", description = "Same as `ffx component config`")]
330pub struct ConfigArgs {
331 #[argh(subcommand)]
332 pub subcommand: ConfigSubcommand,
333}
334
335#[derive(FromArgs, Debug, PartialEq)]
336#[argh(subcommand)]
337pub enum ConfigSubcommand {
338 Set(SetArgs),
339 Unset(UnsetArgs),
340 List(ConfigListArgs),
341}
342
343#[derive(FromArgs, Debug, PartialEq)]
344#[argh(subcommand, name = "set", description = "Same as `ffx component config set`")]
345pub struct SetArgs {
346 #[argh(positional)]
347 pub query: String,
349 #[argh(positional)]
350 pub key_values: Vec<String>,
353 #[argh(switch, short = 'r')]
354 pub reload: bool,
357}
358
359#[derive(FromArgs, Debug, PartialEq)]
360#[argh(subcommand, name = "unset", description = "Same as `ffx component config unset`")]
361pub struct UnsetArgs {
362 #[argh(positional)]
363 pub query: Option<String>,
366 #[argh(switch, short = 'r')]
367 pub reload: bool,
370}
371
372#[derive(FromArgs, Debug, PartialEq)]
373#[argh(subcommand, name = "list", description = "Same as `ffx component config list`")]
374pub struct ConfigListArgs {
375 #[argh(positional)]
376 pub query: String,
378}