workspacer_cli/
get.rs

1// ---------------- [ File: workspacer-cli/src/get.rs ]
2crate::ix!();
3
4#[derive(Debug, StructOpt)]
5pub enum GetSubcommand {
6    /// Get lock-versions from the Cargo.lock
7    LockVersions {
8        #[structopt(long = "path")]
9        workspace_path: Option<PathBuf>,
10
11        #[structopt(long = "skip-git-check")]
12        skip_git_check: bool,
13    },
14
15    /// Get toml section with optional crate selection
16    Toml {
17        #[structopt(long = "section")]
18        section: String,
19
20        #[structopt(long = "crate")]
21        crate_name: Option<String>,
22    },
23}
24
25impl GetSubcommand {
26    /// Main entrypoint: routes to the chosen variant's logic.
27    pub async fn run(&self) -> Result<(), WorkspaceError> {
28        match self {
29            // 1) If user typed `ws get lock-versions ...`
30            GetSubcommand::LockVersions {
31                workspace_path,
32                skip_git_check,
33            } => {
34                get_lock_versions_flow(
35                    workspace_path.clone(),
36                    *skip_git_check
37                ).await
38            },
39
40            // 2) The "ws get toml" subcommand
41            GetSubcommand::Toml { section, crate_name } => {
42                get_toml_section_flow(
43                    section.clone(),
44                    crate_name.clone(),
45                ).await
46            }
47        }
48    }
49}