workspacer_cli/
validate.rs1crate::ix!();
3
4#[derive(Debug, StructOpt)]
6pub enum ValidateSubcommand {
7 Crate {
9 #[structopt(long = "crate")]
11 crate_name: PathBuf,
12 },
13 Workspace {
15 #[structopt(long = "path")]
17 workspace_path: PathBuf,
18 },
19}
20
21impl ValidateSubcommand {
22 pub async fn run(&self) -> Result<(), WorkspaceError> {
23 match self {
24 ValidateSubcommand::Crate { crate_name } => {
25 let handle = CrateHandle::new(crate_name).await.map_err(|crate_err| {
27 WorkspaceError::CrateError(crate_err)
29 })?;
30
31 handle.validate_integrity().await.map_err(|crate_err| {
33 WorkspaceError::CrateError(crate_err)
34 })?;
35
36 println!("Crate at '{}' passed integrity checks!", crate_name.display());
37 }
38
39 ValidateSubcommand::Workspace { workspace_path } => {
40 let ws = Workspace::<PathBuf, CrateHandle>::new(workspace_path).await?;
42
43 ws.validate_integrity().await?;
45
46 println!(
47 "Workspace at '{}' passed integrity checks for all member crates!",
48 workspace_path.display()
49 );
50 }
51 }
52
53 Ok(())
54 }
55}