use std::process::Command;
#[cfg(windows)]
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
pub fn no_console_window(cmd: &mut Command) -> &mut Command {
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
cmd.creation_flags(CREATE_NO_WINDOW);
}
cmd
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn keeps_the_command_it_was_given() {
let mut cmd = Command::new("certutil");
cmd.arg("-user");
let got = no_console_window(&mut cmd);
assert_eq!(got.get_program(), "certutil");
assert_eq!(got.get_args().collect::<Vec<_>>(), ["-user"]);
}
}