format: fix formatting
All checks were successful
/ check (push) Successful in 38s

This commit is contained in:
Didier Slof 2023-07-17 21:23:59 +02:00
parent f51c5dc9d5
commit f050daf035
Signed by: didier
GPG key ID: 01E71F18AA4398E5
12 changed files with 80 additions and 85 deletions

View file

@ -10,11 +10,7 @@ pub struct Process {
impl Process {
pub fn new(command: Vec<String>, cwd: Option<String>, env: Vec<String>) -> Process {
Process {
command,
cwd,
env,
}
Process { command, cwd, env }
}
pub fn command<S: Into<String>>(cmd: Vec<S>) -> Process {
@ -27,7 +23,10 @@ impl Process {
.current_dir(self.cwd.clone().unwrap_or(".".to_string()))
.envs(self.env.iter().map(|v| {
let mut split = v.split('=');
(split.next().unwrap().to_string(), split.next().unwrap().to_string())
(
split.next().unwrap().to_string(),
split.next().unwrap().to_string(),
)
}))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
@ -41,4 +40,4 @@ impl Default for Process {
fn default() -> Process {
Process::new(vec![], None, vec![])
}
}
}

View file

@ -1,10 +1,10 @@
// create functions that spawn threads for Stdout and Stderr
// that print the output to info!(target: "command:stdout", ...) and info!(target: "command:stderr", ...) respectively
use std::process::Child;
use std::io::{BufRead, BufReader};
use std::process::Child;
use log::{info, error};
use log::{error, info};
pub fn spawn_output_handlers(child: &mut Child) {
let stdout = child.stdout.take().unwrap();
@ -23,4 +23,4 @@ pub fn spawn_output_handlers(child: &mut Child) {
error!(target: "command:stderr", "{}", line.unwrap());
}
});
}
}