use std::process::Command;
pub const CREATE_NO_WINDOW: u32 = 0x0800_0000;
pub trait NoWindow {
fn no_window(&mut self) -> &mut Self;
}
impl NoWindow for Command {
#[cfg(windows)]
fn no_window(&mut self) -> &mut Self {
use std::os::windows::process::CommandExt as _;
self.creation_flags(CREATE_NO_WINDOW)
}
#[cfg(not(windows))]
fn no_window(&mut self) -> &mut Self {
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn no_window_keeps_the_command() {
let mut c = Command::new("prog");
c.arg("a").no_window().arg("b");
assert_eq!(c.get_args().collect::<Vec<_>>(), ["a", "b"]);
}
}