1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ---------------- [ File: workspacer-cli/src/pin.rs ]
crate::ix!();
#[derive(Debug, StructOpt)]
pub enum PinSubcommand {
/// Pin wildcard dependencies in a single crate
Crate {
#[structopt(long = "crate")]
crate_name: PathBuf,
#[structopt(long = "skip-git-check")]
skip_git_check: bool,
},
/// Pin wildcard dependencies in an entire workspace
Workspace {
#[structopt(long = "path")]
path: PathBuf,
#[structopt(long = "skip-git-check")]
skip_git_check: bool,
},
}
impl PinSubcommand {
pub async fn run(&self) -> Result<(), WorkspaceError> {
match self {
// ----------------------------------------------------
// 1) Single crate
// ----------------------------------------------------
PinSubcommand::Crate { crate_name, skip_git_check } => {
trace!("Pinning wildcard deps for single crate at '{}'", crate_name.display());
// We'll use the `run_with_crate` helper so we load the crate,
// optionally check Git, etc., then call `pin_all_wildcard_dependencies()`.
run_with_crate(crate_name.clone(), *skip_git_check, |handle| {
Box::pin(async move {
// The `PinAllWildcardDependencies` trait is implemented for `CrateHandle`
handle.pin_all_wildcard_dependencies().await.map_err(|crate_err| {
error!("Failed to pin wildcard deps in crate='{}': {:?}", handle.name(), crate_err);
WorkspaceError::CrateError(crate_err)
})?;
info!("Successfully pinned wildcard dependencies for crate='{}'", handle.name());
Ok(())
})
})
.await
}
// ----------------------------------------------------
// 2) Entire workspace
// ----------------------------------------------------
PinSubcommand::Workspace { path, skip_git_check } => {
trace!("Pinning wildcard deps for workspace at '{}'", path.display());
// We'll use `run_with_workspace` to load the workspace,
// optionally check Git, then call `pin_all_wildcard_dependencies()`.
run_with_workspace(Some(path.clone()), *skip_git_check, |ws| {
Box::pin(async move {
// The `PinAllWildcardDependencies` trait is implemented for `Workspace<P,H>`
ws.pin_all_wildcard_dependencies().await.map_err(|we| {
error!(
"Failed to pin wildcard dependencies in workspace at '{}': {:?}",
ws.as_ref().display(),
we
);
we
})?;
info!("Successfully pinned wildcard dependencies in workspace at '{}'", ws.as_ref().display());
Ok(())
})
})
.await
}
}
}
}