Streamline command runner a bit
This commit is contained in:
parent
ddf645e19e
commit
0a6b6efd7a
2 changed files with 3 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ pub fn is_success(res: Result<Output, impl Error + 'static>) -> Result<Output, B
|
||||||
check_success(res?)
|
check_success(res?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output(output: Output) -> Result<Vec<u8>, Box<dyn Error>> {
|
pub fn get_stdout(output: Output) -> Result<Vec<u8>, Box<dyn Error>> {
|
||||||
Ok(check_success(output)?.stdout)
|
Ok(check_success(output)?.stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ pub trait CommandRunner {
|
||||||
args: &'a [&'a OsStr],
|
args: &'a [&'a OsStr],
|
||||||
) -> Result<Vec<u8>, Box<dyn Error>> {
|
) -> Result<Vec<u8>, Box<dyn Error>> {
|
||||||
let output = self.run_with_args(program, args).await?;
|
let output = self.run_with_args(program, args).await?;
|
||||||
get_output(output)
|
get_stdout(output)
|
||||||
}
|
}
|
||||||
async fn run_successfully<'a>(
|
async fn run_successfully<'a>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl<C: AsRef<[u8]>, U: AsRef<str>, R: CommandRunner> Symbol for Cron<'_, C, U,
|
||||||
.run(
|
.run(
|
||||||
"crontab",
|
"crontab",
|
||||||
args!["-u", self.user.as_ref(), "-",],
|
args!["-u", self.user.as_ref(), "-",],
|
||||||
self.content.as_ref(),
|
self.content.as_ref(), // input
|
||||||
)
|
)
|
||||||
.await,
|
.await,
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue