use bare_script::sync::CommandBuilder;
use std::time::Duration;
use thiserror as _;
use tokio as _;
fn main() {
#[cfg(windows)]
let result = {
CommandBuilder::new("cmd")
.args(["/C", "ping -n 10 127.0.0.1"])
.capture_output()
.execute_with_timeout(Duration::from_millis(100))
};
#[cfg(not(windows))]
let result = {
CommandBuilder::new("sleep")
.arg("10")
.capture_output()
.execute_with_timeout(Duration::from_millis(100))
};
match result {
Ok(output) => {
println!("Command completed: {}", output.stdout_str());
}
Err(e) => {
println!("Command timed out or failed: {}", e);
}
}
}