diff --git a/adb_cli/src/commands/local.rs b/adb_cli/src/commands/local.rs index 941c2fd..8e4fa9c 100644 --- a/adb_cli/src/commands/local.rs +++ b/adb_cli/src/commands/local.rs @@ -19,8 +19,10 @@ pub enum LocalCommand { /// Run an activity on device specified by the intent Run { /// The package whose activity is to be invoked + #[clap(short = 'p', long = "package")] package: String, /// The activity to be invoked itself, Usually it is MainActivity + #[clap(short = 'a', long = "activity")] activity: String, }, /// Reboot the device diff --git a/adb_cli/src/commands/usb.rs b/adb_cli/src/commands/usb.rs index 2acaad7..fbea473 100644 --- a/adb_cli/src/commands/usb.rs +++ b/adb_cli/src/commands/usb.rs @@ -37,8 +37,10 @@ pub enum UsbCommands { /// Run an activity on device specified by the intent Run { /// The package whose activity is to be invoked + #[clap(short = 'p', long = "package")] package: String, /// The activity to be invoked itself, Usually it is MainActivity + #[clap(short = 'a', long = "activity")] activity: String, }, /// Reboot the device diff --git a/adb_cli/src/main.rs b/adb_cli/src/main.rs index 9e3d2e5..8b50ff0 100644 --- a/adb_cli/src/main.rs +++ b/adb_cli/src/main.rs @@ -66,7 +66,8 @@ fn main() -> Result<()> { } } LocalCommand::Run { package, activity } => { - device.run_activity(&package, &activity)?; + let output = device.run_activity(&package, &activity)?; + std::io::stdout().write_all(&output)?; } LocalCommand::HostFeatures => { let features = device @@ -219,7 +220,8 @@ fn main() -> Result<()> { log::info!("Uploaded {filename} to {path}"); } UsbCommands::Run { package, activity } => { - device.run_activity(&package, &activity)?; + let output = device.run_activity(&package, &activity)?; + std::io::stdout().write_all(&output)?; } } } diff --git a/adb_client/src/adb_device_ext.rs b/adb_client/src/adb_device_ext.rs index 10be474..52b725b 100644 --- a/adb_client/src/adb_device_ext.rs +++ b/adb_client/src/adb_device_ext.rs @@ -29,11 +29,14 @@ pub trait ADBDeviceExt { /// Reboots the device using given reboot type fn reboot(&mut self, reboot_type: RebootType) -> Result<()>; - /// Run an `activity` from a given `package` on device - fn run_activity(&mut self, package: &str, activity: &str) -> Result<()> { + /// Run `activity` from `package` on device. Return the command output. + fn run_activity(&mut self, package: &str, activity: &str) -> Result> { + let mut output = Vec::new(); self.shell_command( ["am", "start", &format!("{package}/{package}.{activity}")], - std::io::stdout(), - ) + &mut output, + )?; + + Ok(output) } }