cw-warp 0.4.0

Scaffold, build, test, and deploy CosmWasm Smart Contracts faster than ever before
use std::{
    io::Write,
    process::{Command, Output},
};

use crate::error::WarpError;

pub trait CommandWithInput {
    fn call_process_with_input(&mut self, input: &str) -> Result<Output, WarpError>;
}

impl CommandWithInput for Command {
    fn call_process_with_input(&mut self, input: &str) -> Result<Output, WarpError> {
        let child = self.spawn()?;

        {
            let mut stdin = child.stdin.as_ref().unwrap();
            stdin.write_all(input.as_bytes())?;
            stdin.flush()?;
        }
        let out = child.wait_with_output()?;
        Ok(out)
    }
}