| 208 | } |
| 209 | |
| 210 | fn run_with_stdin(&self, cwd: &Path, args: &[&str], stdin: Option<&str>) -> Output { |
| 211 | let mut command = Command::new(env!("CARGO_BIN_EXE_atomic")); |
| 212 | command |
| 213 | .args(args) |
| 214 | .current_dir(cwd) |
| 215 | .env("HOME", self.home.path()) |
| 216 | .env("ATOMIC_DAEMON_BIN", "/nonexistent/atomicd") |
| 217 | .env_remove("ATOMIC_RPC") |
| 218 | .env_remove("RUST_LOG") |
| 219 | .stdin(if stdin.is_some() { |
| 220 | Stdio::piped() |
| 221 | } else { |
| 222 | Stdio::null() |
| 223 | }) |
| 224 | .stdout(Stdio::piped()) |
| 225 | .stderr(Stdio::piped()); |
| 226 | match &self.socket { |
| 227 | Some(socket) => { |
| 228 | command |
| 229 | .env("ATOMIC_SERVICE", "reactor") |
| 230 | .env("ATOMIC_DAEMON_SOCKET", socket); |
| 231 | } |
| 232 | None => { |
| 233 | command.env("ATOMIC_SERVICE", "local"); |
| 234 | } |
| 235 | } |
| 236 | let mut child = command.spawn().expect("run atomic"); |
| 237 | if let Some(input) = stdin { |
| 238 | use std::io::Write; |
| 239 | child |
| 240 | .stdin |
| 241 | .take() |
| 242 | .unwrap() |
| 243 | .write_all(input.as_bytes()) |
| 244 | .unwrap(); |
| 245 | } |
| 246 | child.wait_with_output().unwrap() |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | fn text(output: &Output) -> String { |