zed_util/
command.rs

1use std::ffi::OsStr;
2
3#[cfg(target_os = "windows")]
4const CREATE_NO_WINDOW: u32 = 0x0800_0000_u32;
5
6#[cfg(target_os = "windows")]
7pub fn new_std_command(program: impl AsRef<OsStr>) -> std::process::Command {
8    use std::os::windows::process::CommandExt;
9
10    let mut command = std::process::Command::new(program);
11    command.creation_flags(CREATE_NO_WINDOW);
12    command
13}
14
15#[cfg(not(target_os = "windows"))]
16pub fn new_std_command(program: impl AsRef<OsStr>) -> std::process::Command {
17    std::process::Command::new(program)
18}
19
20#[cfg(target_os = "windows")]
21pub fn new_smol_command(program: impl AsRef<OsStr>) -> smol::process::Command {
22    use smol::process::windows::CommandExt;
23
24    let mut command = smol::process::Command::new(program);
25    command.creation_flags(CREATE_NO_WINDOW);
26    command
27}
28
29#[cfg(not(target_os = "windows"))]
30pub fn new_smol_command(program: impl AsRef<OsStr>) -> smol::process::Command {
31    smol::process::Command::new(program)
32}