workspacer_cli/analyze_workspace.rs
1// ---------------- [ File: workspacer-cli/src/analyze_workspace.rs ]
2crate::ix!();
3
4/// For analyzing an entire workspace, we define a similar struct but without a crate name.
5/// We just need to know (optionally) the workspace path and skip-git-check.
6#[derive(Debug, StructOpt, Getters, Setters)]
7#[getset(get="pub")]
8pub struct AnalyzeWorkspaceCommand {
9 /// If provided, we use this as the workspace root
10 #[structopt(long = "path")]
11 workspace_path: Option<PathBuf>,
12
13 /// Skip Git clean check
14 #[structopt(long = "skip-git-check")]
15 skip_git_check: bool,
16}
17
18impl AnalyzeWorkspaceCommand {
19 #[tracing::instrument(level="trace", skip(self))]
20 pub async fn run(&self) -> Result<(), WorkspaceError> {
21 // We define a simpler helper that loads the workspace
22 // and optionally checks Git, but does not require a crate name.
23 // We'll call it `run_with_workspace`.
24 run_with_workspace(
25 self.workspace_path().clone(),
26 *self.skip_git_check(),
27 |ws| {
28 Box::pin(async move {
29 // Here we do a full workspace analysis via `ws.analyze()`.
30 // That returns a `WorkspaceSizeAnalysis`.
31 let analysis = ws.analyze().await?;
32 info!("Workspace analysis complete.\n{:#?}",analysis);
33 Ok(())
34 })
35 },
36 ).await
37 }
38}