one_command/
blocking.rs

1use std::ffi::OsStr;
2#[cfg(windows)]
3use std::os::windows::process::CommandExt;
4
5#[cfg(windows)]
6const CREATE_NO_WINDOW: u32 = 0x08000000;
7
8/// Execute commands on the Windows platform,
9/// without opening a window to maintain consistency with other system behaviors.
10pub struct Command;
11
12impl Command {
13    #[allow(clippy::new_ret_no_self)]
14    pub fn new<S: AsRef<OsStr>>(program: S) -> std::process::Command {
15        #[cfg(windows)]
16        {
17            let mut inner = std::process::Command::new(program);
18            inner.creation_flags(CREATE_NO_WINDOW);
19            inner
20        }
21        #[cfg(not(windows))]
22        std::process::Command::new(program)
23    }
24}