MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / exec

Method exec

crates/update/src/cli/uninstall.rs:16–39  ·  view source on GitHub ↗
(self, paths: &SpacetimePaths)

Source from the content-addressed store, hash-verified

14
15impl Uninstall {
16 pub(super) fn exec(self, paths: &SpacetimePaths) -> anyhow::Result<()> {
17 let Self { version, yes } = self;
18 anyhow::ensure!(
19 version != BinDir::CURRENT_VERSION_DIR_NAME,
20 "cannot remove `current` version"
21 );
22 match paths
23 .cli_bin_dir
24 .current_version()
25 .context("couldn't read current version")
26 {
27 Ok(Some(current)) => anyhow::ensure!(version != current, "cannot uninstall currently used version"),
28 Ok(None) => {}
29 Err(e) => tracing::warn!("{e:#}"),
30 }
31 let dir = paths.cli_bin_dir.version_dir(&version);
32 if !dir.0.exists() {
33 anyhow::bail!("v{version} is not installed");
34 }
35 if yes.confirm(format!("Uninstall v{version}?"))? {
36 std::fs::remove_dir_all(&dir)?;
37 }
38 Ok(())
39 }
40}
41
42#[cfg(test)]

Callers

nothing calls this directly

Calls 4

current_versionMethod · 0.80
version_dirMethod · 0.80
confirmMethod · 0.80
OkFunction · 0.50

Tested by

no test coverage detected