refactor: ♻️ Add uninstall method

This commit is contained in:
Sergio Gasquez 2022-12-27 10:21:25 +01:00
parent 8f2ce52020
commit f25545e0f3

View File

@ -10,7 +10,10 @@ use crate::{
use async_trait::async_trait; use async_trait::async_trait;
use log::{info, warn}; use log::{info, warn};
use miette::Result; use miette::Result;
use std::path::{Path, PathBuf}; use std::{
fs::remove_dir_all,
path::{Path, PathBuf},
};
const DEFAULT_LLVM_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download"; const DEFAULT_LLVM_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download";
const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221201"; const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221201";
@ -78,6 +81,14 @@ impl Llvm {
version, version,
} }
} }
/// Uninstall LLVM toolchain.
pub fn uninstall(llvm_path: &Path) -> Result<(), Error> {
info!("{} Deleting Xtensa LLVM", emoji::WRENCH);
remove_dir_all(llvm_path)
.map_err(|_| Error::FailedToRemoveDirectory(llvm_path.display().to_string()))?;
Ok(())
}
} }
#[async_trait] #[async_trait]