1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use clap::{Parser, Subcommand};
mod dev;
mod doctor;
mod new;
mod watch;
#[derive(Parser)]
#[command(name = "mobiler", version, about = "Rust + Compose mobile framework CLI")]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
/// Check that this host has everything needed to build Mobiler apps.
Doctor,
/// Scaffold a new Mobiler project.
New {
/// Project name (becomes the directory and Gradle root name).
name: String,
/// Android application/package id. Defaults to `dev.mobiler.<name>`.
#[arg(long)]
package: Option<String>,
},
/// Build the Mobiler project, install, and launch (default: all three).
Dev {
/// Build only — don't install on a device.
#[arg(long)]
no_install: bool,
/// Build (and install if applicable) but don't launch the activity.
#[arg(long)]
no_run: bool,
},
/// Watch shared/ and Android/ for changes; rebuild + reinstall + relaunch on each change.
Watch {
/// Build only on each change — don't install on a device.
#[arg(long)]
no_install: bool,
/// Build (and install if applicable) but don't launch the activity.
#[arg(long)]
no_run: bool,
},
}
fn main() -> std::process::ExitCode {
let cli = Cli::parse();
match cli.command {
Command::Doctor => doctor::run(),
Command::New { name, package } => match new::run(&name, package.as_deref()) {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e:#}");
std::process::ExitCode::FAILURE
}
},
Command::Dev { no_install, no_run } => match dev::run(no_install, no_run) {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e:#}");
std::process::ExitCode::FAILURE
}
},
Command::Watch { no_install, no_run } => match watch::run(no_install, no_run) {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e:#}");
std::process::ExitCode::FAILURE
}
},
}
}