workspacer_cli/analyze.rs
1// ---------------- [ File: workspacer-cli/src/analyze.rs ]
2crate::ix!();
3
4/// First, let’s extend our `AnalyzeSubcommand` to handle two variants:
5/// - **Crate**: analyze a single crate within the workspace
6/// - **Workspace**: analyze the entire workspace
7///
8/// We’ll do so by defining two small “command structs” with appropriate fields
9/// (e.g., optional `workspace_path`, a `skip_git_check` flag, and so on).
10/// Then each variant will delegate to that struct’s `.run()` method.
11#[derive(Debug, StructOpt)]
12pub enum AnalyzeSubcommand {
13 /// Analyze a single crate by name (must be part of a valid workspace).
14 #[structopt(name = "crate")]
15 Crate(AnalyzeCrateCommand),
16
17 /// Analyze the entire workspace
18 #[structopt(name = "workspace")]
19 Workspace(AnalyzeWorkspaceCommand),
20}
21
22impl AnalyzeSubcommand {
23 #[tracing::instrument(level="trace", skip(self))]
24 pub async fn run(&self) -> Result<(), WorkspaceError> {
25 match self {
26 AnalyzeSubcommand::Crate(cmd) => {
27 cmd.run().await?;
28 }
29 AnalyzeSubcommand::Workspace(cmd) => {
30 cmd.run().await?;
31 }
32 }
33 Ok(())
34 }
35}