feat: add wait-for-device command (#96)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use adb_client::{ADBServer, DeviceShort, MDNSBackend, Result};
|
||||
use adb_client::{ADBServer, DeviceShort, MDNSBackend, Result, WaitForDeviceState};
|
||||
|
||||
use crate::models::{HostCommand, MdnsCommand, ServerCommand};
|
||||
|
||||
@@ -72,6 +72,10 @@ pub fn handle_host_commands(server_command: ServerCommand<HostCommand>) -> Resul
|
||||
HostCommand::ServerStatus => {
|
||||
log::info!("{}", adb_server.server_status()?);
|
||||
}
|
||||
HostCommand::WaitForDevice { transport } => {
|
||||
log::info!("waiting for device to be connected...");
|
||||
adb_server.wait_for_device(WaitForDeviceState::Device, transport)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
use std::net::SocketAddrV4;
|
||||
|
||||
use adb_client::{RustADBError, WaitForDeviceTransport};
|
||||
use clap::Parser;
|
||||
|
||||
fn parse_wait_for_device_device_transport(
|
||||
value: &str,
|
||||
) -> Result<WaitForDeviceTransport, RustADBError> {
|
||||
WaitForDeviceTransport::try_from(value)
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub enum HostCommand {
|
||||
/// Print current ADB version.
|
||||
@@ -28,6 +35,12 @@ pub enum HostCommand {
|
||||
},
|
||||
/// Display server status
|
||||
ServerStatus,
|
||||
/// Wait for a device, on optionally given transport
|
||||
WaitForDevice {
|
||||
/// Transport on which wait for devices
|
||||
#[clap(short = 't', long = "transport", value_parser = parse_wait_for_device_device_transport)]
|
||||
transport: Option<WaitForDeviceTransport>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user