|
1 | | -use anyhow::{anyhow, bail, Context, Result}; |
2 | | -use clap::{ArgAction, Parser}; |
3 | | - |
4 | | -#[derive(Parser, Debug)] |
5 | | -pub struct Run { |
6 | | - /// Should build in release mode |
7 | | - #[clap(short, long, default_value="false", action = ArgAction::SetTrue)] |
8 | | - release: bool, |
9 | | -} |
10 | | - |
11 | | -pub fn handle(args: Run) -> Result<()> { |
12 | | - // Trigger a build |
13 | | - let build_status = android_cli::trigger_build(args.release)?; |
14 | | - if !build_status.success() { |
15 | | - bail!("failed to build project"); |
16 | | - } |
17 | | - |
18 | | - // Request an install to device |
19 | | - let install_status = android_cli::install_apk(args.release)?; |
20 | | - if !install_status.success() { |
21 | | - bail!("failed to install APK"); |
22 | | - } |
23 | | - |
24 | | - // Fetch and deserialize .android |
25 | | - let dot_android = android_cli::get_dot_android() |
26 | | - .ok_or_else(|| anyhow!(".android not found, can't launch activity"))?; |
27 | | - |
28 | | - // Try to launch MainActivity using ADB |
29 | | - let launch_status = |
30 | | - android_cli::launch_activity(dot_android.package_id, dot_android.main_activity_name)?; |
31 | | - if !launch_status.success() { |
32 | | - bail!("failed to launch activity"); |
33 | | - } |
34 | | - |
35 | | - Ok(()) |
36 | | -} |
| 1 | +use anyhow::{anyhow, bail, Result}; |
| 2 | +use clap::{ArgAction, Parser}; |
| 3 | + |
| 4 | +#[derive(Parser, Debug)] |
| 5 | +pub struct Run { |
| 6 | + /// Should build in release mode |
| 7 | + #[clap(short, long, default_value="false", action = ArgAction::SetTrue)] |
| 8 | + release: bool, |
| 9 | +} |
| 10 | + |
| 11 | +pub fn handle(args: Run) -> Result<()> { |
| 12 | + // Trigger a build |
| 13 | + let build_status = android_cli::trigger_build(args.release)?; |
| 14 | + if !build_status.success() { |
| 15 | + bail!("failed to build project"); |
| 16 | + } |
| 17 | + |
| 18 | + // Request an install to device |
| 19 | + let install_status = android_cli::install_apk(args.release)?; |
| 20 | + if !install_status.success() { |
| 21 | + bail!("failed to install APK"); |
| 22 | + } |
| 23 | + |
| 24 | + // Fetch and deserialize .android |
| 25 | + let dot_android = android_cli::get_dot_android() |
| 26 | + .ok_or_else(|| anyhow!(".android not found, can't launch activity"))?; |
| 27 | + |
| 28 | + // Try to launch MainActivity using ADB |
| 29 | + let launch_status = |
| 30 | + android_cli::launch_activity(dot_android.package_id, dot_android.main_activity_name)?; |
| 31 | + if !launch_status.success() { |
| 32 | + bail!("failed to launch activity"); |
| 33 | + } |
| 34 | + |
| 35 | + Ok(()) |
| 36 | +} |
0 commit comments