refact(rustup): use run_external_command
This commit is contained in:
@@ -173,10 +173,7 @@ impl Backend for Rustup {
|
|||||||
_ => bail!("No such type is managed by rustup!"),
|
_ => bail!("No such type is managed by rustup!"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = cmd.status().context("Installing toolchain {p}");
|
run_external_command(cmd).with_context(|| format!("Installing toolchain {p}"))?;
|
||||||
if !result.as_ref().is_ok_and(|exit| exit.success()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(ExitStatus::from_raw(0))
|
Ok(ExitStatus::from_raw(0))
|
||||||
}
|
}
|
||||||
@@ -199,32 +196,28 @@ impl Backend for Rustup {
|
|||||||
removed_toolchains.push(name);
|
removed_toolchains.push(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
run_external_command(cmd)?;
|
run_external_command(cmd)
|
||||||
|
.with_context(|| format!("removing toolchains [{toolchains:?}]"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for component in components {
|
for component_package in components {
|
||||||
let mut cmd = Command::new(self.get_binary());
|
let mut cmd = Command::new(self.get_binary());
|
||||||
cmd.args(get_remove_switches(Repotype::Component));
|
cmd.args(get_remove_switches(Repotype::Component));
|
||||||
|
|
||||||
if toolchain_of_component_was_already_removed(&removed_toolchains, &component) {
|
if toolchain_of_component_was_already_removed(&removed_toolchains, &component_package) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.arg(&component.toolchain);
|
cmd.arg(&component_package.toolchain);
|
||||||
|
|
||||||
cmd.arg(
|
cmd.arg(
|
||||||
component
|
component_package
|
||||||
.component
|
.component
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("the constructor ensures this cannot be None"),
|
.expect("the constructor ensures this cannot be None"),
|
||||||
);
|
);
|
||||||
|
|
||||||
let result = cmd
|
run_external_command(cmd)
|
||||||
.status()
|
.with_context(|| format!("removing component {component_package:?}"))?;
|
||||||
.with_context(|| format!("Removing toolchain {:?})", component));
|
|
||||||
if !result.as_ref().is_ok_and(|exit| exit.success()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(ExitStatus::from_raw(0))
|
Ok(ExitStatus::from_raw(0))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user