component_debug/cli/
capability.rs
1use crate::capability::*;
6use anyhow::Result;
7use fidl_fuchsia_sys2 as fsys;
8
9pub async fn capability_cmd<W: std::io::Write>(
10 query: String,
11 realm_query: fsys::RealmQueryProxy,
12 mut writer: W,
13) -> Result<()> {
14 let segments = get_all_route_segments(query, &realm_query).await?;
15
16 let mut decls = vec![];
17 let mut exposes = vec![];
18 let mut offers = vec![];
19 let mut uses = vec![];
20
21 for s in segments {
22 match &s {
23 RouteSegment::DeclareBy { .. } => decls.push(s),
24 RouteSegment::ExposeBy { .. } => exposes.push(s),
25 RouteSegment::OfferBy { .. } => offers.push(s),
26 RouteSegment::UseBy { .. } => uses.push(s),
27 }
28 }
29
30 if decls.is_empty() {
31 writeln!(writer, "Declarations: None")?;
32 } else {
33 writeln!(writer, "Declarations:")?;
34 for decl in decls {
35 writeln!(writer, " {}", decl)?;
36 }
37 }
38
39 writeln!(writer, "")?;
40
41 if exposes.is_empty() {
42 writeln!(writer, "Exposes: None")?;
43 } else {
44 writeln!(writer, "Exposes:")?;
45 for decl in exposes {
46 writeln!(writer, " {}", decl)?;
47 }
48 }
49
50 writeln!(writer, "")?;
51
52 if offers.is_empty() {
53 writeln!(writer, "Offers: None")?;
54 } else {
55 writeln!(writer, "Offers:")?;
56 for decl in offers {
57 writeln!(writer, " {}", decl)?;
58 }
59 }
60
61 writeln!(writer, "")?;
62
63 if uses.is_empty() {
64 writeln!(writer, "Uses: None")?;
65 } else {
66 writeln!(writer, "Uses:")?;
67 for decl in uses {
68 writeln!(writer, " {}", decl)?;
69 }
70 }
71
72 Ok(())
73}