diff --git a/src/commands/launch.rs b/src/commands/launch.rs new file mode 100644 index 0000000..043e064 --- /dev/null +++ b/src/commands/launch.rs @@ -0,0 +1,21 @@ +use clap::Parser; +use anyhow::{Result, bail, anyhow}; + +#[derive(Parser, Debug)] +pub struct Launch {} + +pub fn handle(_args: Launch) -> Result<()> { + // Fetch and deserialize .android + let dot_android = android_cli::get_dot_android() + .ok_or_else(|| anyhow!(".android not found, can't launch activity"))?; + + // Try to launch MainActivity using ADB + let launch_status = + android_cli::launch_activity(dot_android.package_id, dot_android.main_activity_name)?; + + if !launch_status.success() { + bail!("failed to launch activity"); + } + + Ok(()) +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 291abff..1a62c38 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -2,3 +2,4 @@ pub mod build; pub mod create; pub mod install; pub mod run; +pub mod launch; diff --git a/src/main.rs b/src/main.rs index aa3432c..0518f45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ enum SubCommand { Build(commands::build::Build), Install(commands::install::Install), Run(commands::run::Run), + Launch(commands::launch::Launch) } fn main() { @@ -32,6 +33,7 @@ fn main() { SubCommand::Build(args) => commands::build::handle(args), SubCommand::Install(args) => commands::install::handle(args), SubCommand::Run(args) => commands::run::handle(args), + SubCommand::Launch(args) => commands::launch::handle(args) }; if result.is_err() {