(self, paths: &SpacetimePaths)
| 14 | |
| 15 | impl 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)] |
nothing calls this directly
no test coverage detected