feat(rustup): Remove packages
Signed-off-by: innocentzero <isfarulhaque@proton.me>
This commit is contained in:
@@ -90,20 +90,23 @@ impl Backend for Rustup {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_packages(
|
||||||
|
&self,
|
||||||
|
packages: &[Package],
|
||||||
|
_: bool,
|
||||||
|
) -> anyhow::Result<std::process::ExitStatus> {
|
||||||
|
let mut result: anyhow::Result<std::process::ExitStatus> =
|
||||||
|
Ok(std::process::ExitStatus::from_raw(0));
|
||||||
for p in packages {
|
for p in packages {
|
||||||
let repo = p
|
let repo = p
|
||||||
.repo
|
.repo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Not specified wether it is a component or a toolchain!");
|
.expect("Not specified whether it is a toolchain or a component!");
|
||||||
if repo == "component" {
|
if repo == "toolchain" {
|
||||||
let mut iter = p.name.split('/');
|
|
||||||
let toolchain = iter.next().expect("Toolchain not specified!");
|
|
||||||
let component = iter.next().expect("Component not specified!");
|
|
||||||
let mut cmd = Command::new(self.get_binary());
|
let mut cmd = Command::new(self.get_binary());
|
||||||
cmd.args(&[&"component", &"add"]);
|
cmd.args(self.get_remove_switches(repo));
|
||||||
cmd.args([&"--toolchain", format!("{toolchain}").as_str()]);
|
cmd.arg(format!("{}", p.name));
|
||||||
cmd.arg(format!("{component}"));
|
result = cmd.status().context("Removing toolchain {p}");
|
||||||
result = cmd.status().context("Installing component {p}");
|
|
||||||
if !result.as_ref().is_ok_and(|exit| exit.success()) {
|
if !result.as_ref().is_ok_and(|exit| exit.success()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -128,6 +131,14 @@ impl Rustup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_remove_switches(&self, repotype: &str) -> Switches {
|
||||||
|
match repotype {
|
||||||
|
"toolchain" => &["toolchain", "uninstall"],
|
||||||
|
"component" => &["component", "remove", "--toolchain"],
|
||||||
|
_ => panic!("No such type managed by rust"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_info_switches(&self, repotype: &str) -> Switches {
|
fn get_info_switches(&self, repotype: &str) -> Switches {
|
||||||
match repotype {
|
match repotype {
|
||||||
"toolchain" => &["toolchain", "list"],
|
"toolchain" => &["toolchain", "list"],
|
||||||
|
|||||||
Reference in New Issue
Block a user