workspacer_show/
show_all.rs1crate::ix!();
3
4#[async_trait]
5pub trait ShowAll {
6
7 type Error;
8
9 async fn show_all(&self, options: &ShowFlags) -> Result<String, Self::Error>;
10}
11
12#[async_trait]
13impl<P, H> ShowAll for Workspace<P, H>
14where
15 for<'a> P: From<PathBuf> + AsRef<Path> + Clone + Send + Sync + 'a,
16 for<'a> H: CrateHandleInterface<P> + ShowItem<Error = CrateError> + Send + Sync + 'a,
17{
18 type Error = WorkspaceError;
19
20 #[tracing::instrument(level = "trace", skip(self, options))]
21 async fn show_all(&self, options: &ShowFlags) -> Result<String, Self::Error> {
22 trace!("Entering ShowWorkspace::show_workspace at path={:?}", self.as_ref());
23
24 let mut output = String::new();
26
27 let crates_list = self.crates();
28 if crates_list.is_empty() && *options.show_items_with_no_data() {
29 return Ok("<no-data-for-crate>\n".to_string());
30 }
31
32 for crate_arc in crates_list {
34 let mut guard = crate_arc.lock().await;
35 let mut local_opts = options.clone();
40 local_opts.set_merge_crates(false);
42
43 let cci_str = guard.show(&local_opts).await.map_err(WorkspaceError::CrateError)?;
44 let crate_name = guard.name();
45 let info_line = format!("// ---------------- [ Crate: {} ]\n", crate_name);
46 info!("{}", info_line.trim());
47
48 if cci_str.trim().is_empty() {
49 if *options.show_items_with_no_data() {
50 output.push_str(&info_line);
51 output.push_str("<no-data-for-crate>\n\n");
52 }
53 } else {
54 output.push_str(&info_line);
55 output.push_str(&cci_str);
56 output.push('\n');
57 }
58 }
59
60 if output.trim().is_empty() && *options.show_items_with_no_data() {
61 output = "<no-data>\n".to_string();
62 }
63
64 Ok(output)
65 }
66}