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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
use clap::{Parser, Subcommand};
use std::path::PathBuf;
mod commands;
mod config;
mod platform;
mod templating;
#[derive(Parser)]
#[command(name = "jffi")]
#[command(about = "JFFI - Cross-platform app framework with Rust + native UIs", long_about = None)]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Create a new cross-platform app
New {
/// Project name
name: String,
/// Target platforms (comma-separated: ios,android,macos,windows,linux,web,multi)
#[arg(short, long)]
platforms: Option<String>,
/// Project template (todo, hello, counter)
#[arg(short, long)]
template: Option<String>,
/// Project directory (defaults to current directory)
#[arg(short = 'd', long)]
path: Option<PathBuf>,
},
/// Build the app for specific platform(s)
Build {
/// Platform to build (ios, android, macos-arm64, macos-x64, windows-x64, windows-x86, linux, web)
#[arg(short, long)]
platform: Option<String>,
/// Build all enabled platforms
#[arg(short, long)]
all: bool,
/// Release build
#[arg(short, long)]
release: bool,
/// Build for physical device (iOS only)
#[arg(short, long)]
device: bool,
/// Build for deployment (all architectures for Windows, otherwise same as default)
#[arg(long)]
deploy: bool,
/// Show verbose build output
#[arg(short, long)]
verbose: bool,
/// Skip auto-generation of Android ndk-context JNI bridge
#[arg(long)]
no_android_bridge: bool,
},
/// Run the app on specific platform
Run {
/// Platform to run on
#[arg(short, long, default_value = "ios")]
platform: String,
/// Run on physical device (iOS only)
#[arg(short, long)]
device: bool,
/// Show verbose build output
#[arg(short, long)]
verbose: bool,
/// Skip auto-generation of Android ndk-context JNI bridge
#[arg(long)]
no_android_bridge: bool,
},
/// Watch mode - auto-rebuild on changes
Dev {
/// Platform to develop for
#[arg(short, long, default_value = "ios")]
platform: String,
/// Show verbose build output
#[arg(short, long)]
verbose: bool,
/// Skip auto-generation of Android ndk-context JNI bridge
#[arg(long)]
no_android_bridge: bool,
},
/// Add a new platform to existing project
Add {
/// Platform to add
platform: String,
},
/// Remove a platform from existing project
Remove {
/// Platform to remove
platform: String,
},
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::New { name, platforms, template, path } => {
commands::new::create_project(&name, platforms.as_deref(), template.as_deref(), path)?;
}
Commands::Build { platform, all, release, device, deploy, verbose, no_android_bridge } => {
if verbose {
std::env::set_var("JFFI_VERBOSE", "1");
}
if no_android_bridge {
std::env::set_var("JFFI_NO_ANDROID_BRIDGE", "1");
}
commands::build::build_project(platform, all, release, device, deploy)?;
}
Commands::Run { platform, device, verbose, no_android_bridge } => {
if verbose {
std::env::set_var("JFFI_VERBOSE", "1");
}
if no_android_bridge {
std::env::set_var("JFFI_NO_ANDROID_BRIDGE", "1");
}
commands::run::run_project(&platform, device)?;
}
Commands::Dev { platform, verbose, no_android_bridge } => {
if verbose {
std::env::set_var("JFFI_VERBOSE", "1");
}
if no_android_bridge {
std::env::set_var("JFFI_NO_ANDROID_BRIDGE", "1");
}
commands::dev::watch_project(&platform)?;
}
Commands::Add { platform } => {
commands::add::add_platform(&platform)?;
}
Commands::Remove { platform } => {
commands::remove::remove_platform(&platform)?;
}
}
Ok(())
}