workspacer_cli/
cleanup_workspace.rs

1// ---------------- [ File: workspacer-cli/src/cleanup_workspace.rs ]
2crate::ix!();
3
4/// For **Workspace** subcommand usage: `ws cleanup workspace [--path ...] [--skip-git-check]`
5#[derive(Debug, StructOpt, Getters, Setters)]
6#[getset(get="pub")]
7pub struct CleanupWorkspaceCommand {
8    /// If provided, we use this path as the workspace root
9    #[structopt(long = "path")]
10    workspace_path: Option<PathBuf>,
11
12    /// If true, we skip the Git clean check
13    #[structopt(long = "skip-git-check")]
14    skip_git_check: bool,
15}
16
17impl CleanupWorkspaceCommand {
18    pub async fn run(&self) -> Result<(), WorkspaceError> {
19        // 1) load the workspace, optionally ensure Git is clean
20        run_with_workspace(
21            self.workspace_path().clone(),
22            *self.skip_git_check(),
23            move |ws| {
24                Box::pin(async move {
25                    // 2) call `ws.cleanup_workspace().await`
26                    ws.cleanup_workspace().await?;
27                    info!("Workspace successfully cleaned up (removed top-level target/, Cargo.lock, etc.)");
28                    Ok(())
29                })
30            }
31        ).await
32    }
33}