use std::path::Path;
use std::process::Command;
pub(super) fn mock_shell_command(stdout: &str, stderr: &str, exit_code: i32) -> Command {
let mut command = Command::new("sh");
command.arg("-c").arg(
"printf '%s' \"$ONE_SHOT_STDOUT\"; printf '%s' \"$ONE_SHOT_STDERR\" >&2; exit \
\"$ONE_SHOT_EXIT\"",
);
command.env("ONE_SHOT_STDOUT", stdout);
command.env("ONE_SHOT_STDERR", stderr);
command.env("ONE_SHOT_EXIT", exit_code.to_string());
command.stdout(std::process::Stdio::piped());
command.stderr(std::process::Stdio::piped());
command
}
pub(super) fn stdin_capture_shell_command(capture_path: &Path) -> Command {
let mut command = Command::new("sh");
command
.arg("-c")
.arg("cat > \"$ONE_SHOT_CAPTURE_PATH\"; printf '%s' '{\"answer\":\"captured\"}'");
command.env("ONE_SHOT_CAPTURE_PATH", capture_path);
command.stdout(std::process::Stdio::piped());
command.stderr(std::process::Stdio::piped());
command
}