Skip to content

Commit 4bb6c45

Browse files
committed
feat: implement the launch command
1 parent 49bb3a6 commit 4bb6c45

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/commands/launch.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use clap::Parser;
2+
use anyhow::{Result, bail, anyhow};
3+
4+
#[derive(Parser, Debug)]
5+
pub struct Launch {}
6+
7+
pub fn handle(_args: Launch) -> Result<()> {
8+
// Fetch and deserialize .android
9+
let dot_android = android_cli::get_dot_android()
10+
.ok_or_else(|| anyhow!(".android not found, can't launch activity"))?;
11+
12+
// Try to launch MainActivity using ADB
13+
let launch_status =
14+
android_cli::launch_activity(dot_android.package_id, dot_android.main_activity_name)?;
15+
16+
if !launch_status.success() {
17+
bail!("failed to launch activity");
18+
}
19+
20+
Ok(())
21+
}

src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pub mod build;
22
pub mod create;
33
pub mod install;
44
pub mod run;
5+
pub mod launch;

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum SubCommand {
1919
Build(commands::build::Build),
2020
Install(commands::install::Install),
2121
Run(commands::run::Run),
22+
Launch(commands::launch::Launch)
2223
}
2324

2425
fn main() {
@@ -32,6 +33,7 @@ fn main() {
3233
SubCommand::Build(args) => commands::build::handle(args),
3334
SubCommand::Install(args) => commands::install::handle(args),
3435
SubCommand::Run(args) => commands::run::handle(args),
36+
SubCommand::Launch(args) => commands::launch::handle(args)
3537
};
3638

3739
if result.is_err() {

0 commit comments

Comments
 (0)