Enable arguments in action fields of hooks

This commit is contained in:
finga 2021-03-17 13:40:08 +01:00
parent 72a8a06c42
commit ea19c7e413

View file

@ -61,7 +61,23 @@ fn execute_hook(name: &str, hook: &Hook, data: &serde_json::Value) -> Result<()>
if let Some(action) = &hook.action {
info!("Execute `{}` from hook `{}`", action, name);
Command::new(action).spawn()?;
let action = action.split(" ").collect::<Vec<&str>>();
let command = Command::new(action[0]).args(&action[1..]).output()?;
info!(
"Command `{}` exited with return code: {}",
action[0], command.status
);
debug!(
"Output of command `{}` on stderr: {:?}",
action[0], &command.stderr
);
trace!(
"Output of command `{}` on stdout: {:?}",
action[0],
&command.stdout
);
}
Ok(())