Skip to content

Commit

Permalink
feat: implement the launch command
Browse files Browse the repository at this point in the history
  • Loading branch information
SyedAhkam committed Aug 21, 2023
1 parent 49bb3a6 commit 4bb6c45
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/commands/launch.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pub mod build;
pub mod create;
pub mod install;
pub mod run;
pub mod launch;
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum SubCommand {
Build(commands::build::Build),
Install(commands::install::Install),
Run(commands::run::Run),
Launch(commands::launch::Launch)
}

fn main() {
Expand All @@ -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() {
Expand Down

0 comments on commit 4bb6c45

Please sign in to comment.