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