xtask: split run into two functions in cargo.rs

This commit is contained in:
Mark Poliakov 2025-03-02 00:03:23 +02:00
parent de98ae1082
commit a45c54faf8

View File

@ -36,7 +36,11 @@ pub enum CargoBuilder<'e> {
}
impl<'e> CargoBuilder<'e> {
pub fn run<P: AsRef<Path>, S: AsRef<OsStr>>(self, dir: P, arg: S) -> Result<(), Error> {
fn make_command<P: AsRef<Path>, S: AsRef<OsStr>>(
self,
dir: P,
arg: S,
) -> Result<Command, Error> {
let arg = arg.as_ref();
let mut command = Command::new("cargo");
@ -239,6 +243,12 @@ impl<'e> CargoBuilder<'e> {
// }
}
Ok(command)
}
pub fn run<P: AsRef<Path>, S: AsRef<OsStr>>(self, dir: P, arg: S) -> Result<(), Error> {
let mut command = self.make_command(dir, arg)?;
log::trace!("Run cargo: {:?}", command);
let status = command.status()?;