use std::{
io::Result,
process::{ExitStatus, Output},
};
use tokio::process::Command;
use crate::{builder::CommandGroupBuilder, AsyncGroupChild};
#[doc(inline)]
pub use erased::ErasedChild;
#[cfg(target_family = "windows")]
mod windows;
#[cfg(target_family = "unix")]
mod unix;
pub(crate) mod child;
pub(crate) mod erased;
#[async_trait::async_trait]
pub trait AsyncCommandGroup {
fn group_spawn(&mut self) -> Result<AsyncGroupChild> {
self.group().spawn()
}
fn group(&mut self) -> crate::builder::CommandGroupBuilder<tokio::process::Command>;
async fn group_output(&mut self) -> Result<Output> {
let child = self.group_spawn()?;
child.wait_with_output().await
}
async fn group_status(&mut self) -> Result<ExitStatus> {
let mut child = self.group_spawn()?;
child.wait().await
}
}
#[async_trait::async_trait]
impl AsyncCommandGroup for Command {
fn group<'a>(&'a mut self) -> CommandGroupBuilder<'a, Command> {
CommandGroupBuilder::new(self)
}
}