use hdc_rs::HdcClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_env_filter("hdc_rs=debug")
.init();
println!("Testing Shell Command\n");
let mut client = HdcClient::connect("127.0.0.1:8710").await?;
println!("✓ Connected to server\n");
let devices = client.list_targets().await?;
if devices.is_empty() {
eprintln!("No devices found");
return Ok(());
}
let device = &devices[0];
println!("Device: {}\n", device);
client.connect_device(device).await?;
println!("✓ Connected to device\n");
println!("Testing: echo hello");
match client.shell("echo hello").await {
Ok(output) => {
println!("Success!");
println!("Output: '{}'", output.trim());
println!("Length: {} bytes", output.len());
}
Err(e) => {
eprintln!("Failed: {}", e);
}
}
println!("\nTesting: pwd");
match client.shell("pwd").await {
Ok(output) => {
println!("Success!");
println!("Output: '{}'", output.trim());
}
Err(e) => {
eprintln!("Failed: {}", e);
}
}
println!("\nDone");
Ok(())
}