Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:58:16.847Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

command.rs

129 lines · 3.1 KB · rust
1use std::ffi::OsStr;
2#[cfg(not(target_os = "macos"))]
3use std::path::Path;
4
5#[cfg(target_os = "macos")]
6mod darwin;
7
8#[cfg(target_os = "macos")]
9pub use darwin::{Child, Command, Stdio};
10
11#[cfg(target_os = "windows")]
12const CREATE_NO_WINDOW: u32 = 0x0800_0000_u32;
13
14pub use gpui_util::new_std_command;
15
16pub fn new_command(program: impl AsRef<OsStr>) -> Command {
17    Command::new(program)
18}
19
20#[cfg(not(target_os = "macos"))]
21pub type Child = smol::process::Child;
22
23#[cfg(not(target_os = "macos"))]
24pub use std::process::Stdio;
25
26#[cfg(not(target_os = "macos"))]
27#[derive(Debug)]
28pub struct Command(smol::process::Command);
29
30#[cfg(not(target_os = "macos"))]
31impl Command {
32    #[inline]
33    pub fn new(program: impl AsRef<OsStr>) -> Self {
34        #[cfg(target_os = "windows")]
35        {
36            use smol::process::windows::CommandExt;
37            let mut cmd = smol::process::Command::new(program);
38            cmd.creation_flags(CREATE_NO_WINDOW);
39            Self(cmd)
40        }
41        #[cfg(not(target_os = "windows"))]
42        Self(smol::process::Command::new(program))
43    }
44
45    pub fn arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
46        self.0.arg(arg);
47        self
48    }
49
50    pub fn args<I, S>(&mut self, args: I) -> &mut Self
51    where
52        I: IntoIterator<Item = S>,
53        S: AsRef<OsStr>,
54    {
55        self.0.args(args);
56        self
57    }
58
59    pub fn get_args(&self) -> impl Iterator<Item = &OsStr> {
60        self.0.get_args()
61    }
62
63    pub fn env(&mut self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>) -> &mut Self {
64        self.0.env(key, val);
65        self
66    }
67
68    pub fn envs<I, K, V>(&mut self, vars: I) -> &mut Self
69    where
70        I: IntoIterator<Item = (K, V)>,
71        K: AsRef<OsStr>,
72        V: AsRef<OsStr>,
73    {
74        self.0.envs(vars);
75        self
76    }
77
78    pub fn env_remove(&mut self, key: impl AsRef<OsStr>) -> &mut Self {
79        self.0.env_remove(key);
80        self
81    }
82
83    pub fn env_clear(&mut self) -> &mut Self {
84        self.0.env_clear();
85        self
86    }
87
88    pub fn current_dir(&mut self, dir: impl AsRef<Path>) -> &mut Self {
89        self.0.current_dir(dir);
90        self
91    }
92
93    pub fn stdin(&mut self, cfg: impl Into<Stdio>) -> &mut Self {
94        self.0.stdin(cfg.into());
95        self
96    }
97
98    pub fn stdout(&mut self, cfg: impl Into<Stdio>) -> &mut Self {
99        self.0.stdout(cfg.into());
100        self
101    }
102
103    pub fn stderr(&mut self, cfg: impl Into<Stdio>) -> &mut Self {
104        self.0.stderr(cfg.into());
105        self
106    }
107
108    pub fn kill_on_drop(&mut self, kill_on_drop: bool) -> &mut Self {
109        self.0.kill_on_drop(kill_on_drop);
110        self
111    }
112
113    pub fn spawn(&mut self) -> std::io::Result<Child> {
114        self.0.spawn()
115    }
116
117    pub async fn output(&mut self) -> std::io::Result<std::process::Output> {
118        self.0.output().await
119    }
120
121    pub async fn status(&mut self) -> std::io::Result<std::process::ExitStatus> {
122        self.0.status().await
123    }
124
125    pub fn get_program(&self) -> &OsStr {
126        self.0.get_program()
127    }
128}
129
Served at tenant.openagents/omega Member data and write actions are omitted.