workspacer_cli/
bump_workspace.rs

1// ---------------- [ File: workspacer-cli/src/bump_workspace.rs ]
2crate::ix!();
3
4/// Bump all crates in the workspace at once. We use `BumpAll::bump_all`.
5#[derive(Debug, StructOpt, Getters, Setters)]
6#[getset(get = "pub")]
7pub struct BumpWorkspaceCommand {
8    /// If provided, we use this path as the workspace root
9    #[structopt(long = "path")]
10    workspace_path: Option<PathBuf>,
11
12    /// Skip Git clean check
13    #[structopt(long = "skip-git-check")]
14    skip_git_check: bool,
15
16    /// The release type to apply (major, minor, patch, alpha[=N])
17    #[structopt(long = "release", default_value = "patch")]
18    release_arg: ReleaseArg,
19}
20
21impl BumpWorkspaceCommand {
22    pub async fn run(&self) -> Result<(), WorkspaceError> {
23        let ReleaseArg(release_type) = self.release_arg().clone();
24        // We'll do `run_with_workspace` => load the workspace => call `bump_all(release_type)`
25        run_with_workspace(
26            self.workspace_path().clone(),
27            *self.skip_git_check(),
28            move |ws| {
29                Box::pin(async move {
30                    // `ws` is a &mut Workspace<...>
31                    // We call `BumpAll::bump_all` on it
32                    ws.bump_all(release_type.clone()).await.map_err(|bump_err| {
33                        // Wrap or pass along as a workspace error
34                        error!("Failed to bump all crates in workspace: {:?}", bump_err);
35                        WorkspaceError::from(bump_err)
36                    })?;
37
38                    info!("Successfully bumped entire workspace with release={:?}", release_type);
39                    Ok(())
40                })
41            },
42        )
43        .await
44    }
45}