Skip to main content

euv_cli/args/
enum.rs

1use super::*;
2
3/// CLI target selector covering all 27 supported euv platforms plus `native` and `all`.
4#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
5pub enum TargetArg {
6    /// Browser WebAssembly target (`wasm32-unknown-unknown`).
7    Web,
8    /// Android native NDK target (`aarch64-linux-android`).
9    Android,
10    /// iOS native UIKit/Metal target (`aarch64-apple-ios`).
11    Ios,
12    /// iPadOS native UIKit/Metal target (`aarch64-apple-ios`).
13    Ipad,
14    /// macOS native AppKit/Metal target (`aarch64-apple-darwin` / `x86_64-apple-darwin`).
15    Macos,
16    /// Windows native Win32/D3D12 target (`x86_64-pc-windows-msvc` / `aarch64-pc-windows-msvc`).
17    Windows,
18    /// Linux native Wayland/X11/Vulkan target (`x86_64-unknown-linux-gnu` / `aarch64-unknown-linux-gnu`).
19    Linux,
20    /// Interactive PTY Terminal UI target.
21    Tui,
22    /// Non-interactive static/pipe CLI terminal target.
23    Cli,
24    /// Google/Samsung Wear OS smartwatch target.
25    Wearos,
26    /// Apple watchOS smartwatch target.
27    Watchos,
28    /// Huawei HarmonyOS Watch wearable target.
29    #[value(name = "harmony-wearable")]
30    HarmonyWearable,
31    /// Xiaomi HyperOS / Vela Watch wearable target.
32    Vela,
33    /// vivo BlueOS Watch smartwatch target (`blueos` / `vivo`).
34    #[value(name = "vivo-watch", alias = "blueos", alias = "vivo")]
35    VivoWatch,
36    /// OPPO ColorOS Watch / Wear OS dual-engine smartwatch target.
37    #[value(name = "oppo-watch", alias = "oppo")]
38    OppoWatch,
39    /// Garmin Connect IQ smartwatch target.
40    #[value(name = "garmin")]
41    Garmin,
42    /// Amazfit Zepp OS smartwatch target.
43    #[value(name = "zeppos", alias = "amazfit")]
44    Zeppos,
45    /// Generic smart wearable target building all supported smartwatch ecosystems.
46    Wearable,
47    /// HarmonyOS / OpenHarmony multi-form-factor native target (phone/tablet/pc/foldable/tv/car).
48    Harmony,
49    /// WeChat Mini-Program target (`wx`).
50    Wechat,
51    /// Alipay Mini-Program target (`my`).
52    Alipay,
53    /// Douyin / ByteDance Mini-Program target (`tt`).
54    Douyin,
55    /// Baidu Smart Mini-Program target (`swan`).
56    Baidu,
57    /// QQ Mini-Program target (`qq`).
58    Qq,
59    /// Kuaishou Mini-Program target (`ks`).
60    Kuaishou,
61    /// HarmonyOS Atomic Service target (`atomic`).
62    #[value(name = "harmony-atomic")]
63    HarmonyAtomic,
64    /// QuickApp Alliance / Huawei QuickApp target.
65    Quickapp,
66    /// Current host native target.
67    Native,
68    /// Every supported euv platform.
69    All,
70}
71
72/// Optional HarmonyOS / OpenHarmony device form factor selector for `euv build --target harmony`.
73#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
74pub enum HarmonyFormFactorArg {
75    /// HarmonyOS phone device profile.
76    #[default]
77    Phone,
78    /// HarmonyOS tablet device profile.
79    Tablet,
80    /// HarmonyOS PC / 2-in-1 desktop device profile.
81    Pc,
82    /// HarmonyOS foldable display device profile.
83    Foldable,
84    /// HarmonyOS smart TV / Vision device profile.
85    Tv,
86    /// HarmonyOS automotive / cockpit device profile.
87    Car,
88    /// HarmonyOS smartwatch wearable device profile.
89    Wearable,
90}
91
92/// CLI render pipeline mode selector.
93#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
94pub enum RenderArg {
95    /// Automatically prefer hardware GPU with software fallback.
96    Auto,
97    /// Deterministic software CPU rasterizer.
98    Software,
99    /// Native GPU instanced pipeline.
100    Hardware,
101    /// Hybrid CPU vector + GPU texture compositor.
102    Hybrid,
103}
104
105/// Target mode for the `euv dev` hot-reload and OTA development server.
106#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
107pub enum DevTargetArg {
108    /// Build and live-reload all project Markdown documentation pages.
109    Docs,
110    /// Build and live-reload WebAssembly zero-JS bundles plus Dynamic WASM OTA feed.
111    Web,
112    /// Watch Rust sources, rebuild, hot-restart the native app, and serve Dynamic WASM OTA updates.
113    Native,
114    /// Watch Rust sources and relaunch interactive PTY Terminal UI builds.
115    Tui,
116    /// Watch Rust sources and rerun static/pipe CLI terminal builds.
117    Cli,
118    /// Watch Rust sources and rebuild HarmonyOS HAP bundles.
119    Harmony,
120    /// Watch Rust sources and rebuild wearable smartwatch bundles.
121    Wearable,
122    /// Watch Rust sources and rebuild Mini-Program bundles.
123    Miniapp,
124    /// Watch Rust sources and rebuild QuickApp bundles.
125    Quickapp,
126}
127
128/// Subcommands under `euv docs` for building or live-serving project Markdown documentation.
129#[derive(Clone, Debug, Eq, PartialEq, Subcommand)]
130pub enum DocsAction {
131    /// Builds all Markdown files under a project or docs directory into a static site.
132    Build {
133        /// Shared source, output, title, and base URL flags.
134        #[command(flatten)]
135        build: DocsBuildArgs,
136    },
137    /// Builds and serves Markdown documentation with live file-watching and SSE hot reload.
138    Dev {
139        /// Shared source, output, title, and base URL flags.
140        #[command(flatten)]
141        build: DocsBuildArgs,
142        /// Shared dev server bind, poll interval, and smoke-run flags.
143        #[command(flatten)]
144        server: ServerBindArgs,
145    },
146}
147
148/// Subcommands under `euv update` for operating the Hyperlane HTTP + SSE dynamic update server and local store.
149#[derive(Clone, Debug, Eq, PartialEq, Subcommand)]
150pub enum UpdateAction {
151    /// Starts the read-only Hyperlane HTTP + SSE dynamic update server backed by the local store directory.
152    Serve {
153        /// Local update store root directory (`staging/`, `blobs/`, `releases/`, `channels/`, `state/`).
154        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
155        store: PathBuf,
156        /// Host bind address.
157        #[arg(long, default_value = DEFAULT_UPDATE_SERVER_HOST)]
158        host: String,
159        /// TCP listen port (`0` selects an ephemeral port).
160        #[arg(long, default_value_t = DEFAULT_UPDATE_SERVER_PORT)]
161        port: u16,
162        /// Optional external reverse-proxy base URL (e.g. `https://ota.example.com/euv`).
163        #[arg(long)]
164        proxy_base: Option<String>,
165        /// SSE keep-alive heartbeat interval in milliseconds.
166        #[arg(long, default_value_t = DEFAULT_UPDATE_HEARTBEAT_MS)]
167        heartbeat_ms: u64,
168        /// Background channel pointer watcher polling interval in milliseconds.
169        #[arg(long, default_value_t = DEFAULT_UPDATE_WATCH_POLL_MS)]
170        poll_ms: u64,
171        /// Validate store layout and server bind readiness then exit immediately.
172        #[arg(long, default_value_t = false)]
173        once: bool,
174        /// Print the structured server configuration without binding sockets.
175        #[arg(long, default_value_t = false)]
176        plan: bool,
177    },
178    /// Stages and SHA-256-verifies a release manifest and its blobs into `staging/<stage_id>/`.
179    Stage {
180        /// Local update store root directory.
181        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
182        store: PathBuf,
183        /// Logical project identifier.
184        #[arg(long)]
185        project: String,
186        /// Release channel name (e.g. `prod`).
187        #[arg(long)]
188        channel: String,
189        /// Unique stage identifier name.
190        #[arg(long)]
191        stage_id: String,
192        /// Path to the draft JSON `ReleaseManifest` file.
193        #[arg(long)]
194        manifest: PathBuf,
195        /// Directory containing built artifact blobs referenced by `manifest`.
196        #[arg(long)]
197        blobs_dir: PathBuf,
198    },
199    /// Atomically signs and publishes a staged release with a strictly monotonic sequence number.
200    Publish {
201        /// Local update store root directory.
202        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
203        store: PathBuf,
204        /// Logical project identifier.
205        #[arg(long)]
206        project: String,
207        /// Release channel name.
208        #[arg(long)]
209        channel: String,
210        /// Previously staged directory name under `staging/`.
211        #[arg(long)]
212        stage_id: String,
213        /// Offline HMAC-SHA256 signing secret (or provide `--signing-key-env`).
214        #[arg(long)]
215        signing_key: Option<String>,
216        /// Environment variable name holding the offline signing secret.
217        #[arg(long, default_value = ENV_UPDATE_SIGNING_KEY)]
218        signing_key_env: String,
219    },
220    /// Signs a NEW monotonic release pointing back to a historical release's verified blobs (never replaying old manifests).
221    Rollback {
222        /// Local update store root directory.
223        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
224        store: PathBuf,
225        /// Logical project identifier.
226        #[arg(long)]
227        project: String,
228        /// Release channel name.
229        #[arg(long)]
230        channel: String,
231        /// Historical release sequence whose verified artifacts should be restored.
232        #[arg(long)]
233        to_release: u64,
234        /// Offline HMAC-SHA256 signing secret (or provide `--signing-key-env`).
235        #[arg(long)]
236        signing_key: Option<String>,
237        /// Environment variable name holding the offline signing secret.
238        #[arg(long, default_value = ENV_UPDATE_SIGNING_KEY)]
239        signing_key_env: String,
240    },
241    /// Inspects active channel pointers, release counts, and content-addressed blob inventory in a local update store.
242    Status {
243        /// Local update store root directory.
244        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
245        store: PathBuf,
246        /// Optional project filter.
247        #[arg(long)]
248        project: Option<String>,
249        /// Optional channel filter.
250        #[arg(long)]
251        channel: Option<String>,
252    },
253}
254
255/// Top-level `euv` CLI subcommands.
256#[derive(Clone, Debug, Eq, PartialEq, Subcommand)]
257pub enum Commands {
258    /// Runs an euv application for a target platform and render mode, with optional `--watch` hot reload.
259    Run {
260        /// Target platform to launch.
261        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
262        target: TargetArg,
263        /// Optional HarmonyOS form factor (`phone`, `tablet`, `pc`, `foldable`, `tv`, `car`, `wearable`).
264        #[arg(long, value_enum, default_value_t = HarmonyFormFactorArg::Phone)]
265        form_factor: HarmonyFormFactorArg,
266        /// Rendering pipeline mode.
267        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
268        render: RenderArg,
269        /// Build and run in release mode.
270        #[arg(long, default_value_t = false)]
271        release: bool,
272        /// Optional Cargo package name to run.
273        #[arg(long)]
274        package: Option<String>,
275        /// Enable file-watching hot reload and live OTA update serving.
276        #[arg(short = 'w', long, default_value_t = false)]
277        watch: bool,
278        /// HTTP hot-reload/OTA port when `--watch` is enabled.
279        #[arg(long, default_value_t = 8080)]
280        port: u16,
281        /// Print the execution plan without spawning Cargo.
282        #[arg(long, default_value_t = false)]
283        plan: bool,
284    },
285    /// Starts the hot-reload and Dynamic WASM OTA development server for Web, Native, Docs, Terminal, Harmony, Wearable, MiniApp, or QuickApp.
286    Dev {
287        /// Development pipeline target (`web`, `native`, `docs`, `tui`, `cli`, `harmony`, `wearable`, `miniapp`, `quickapp`).
288        #[arg(long, value_enum, default_value_t = DevTargetArg::Web)]
289        target: DevTargetArg,
290        /// Rendering pipeline mode default.
291        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
292        render: RenderArg,
293        /// Build and serve in release mode when rebuilding Web or Native targets.
294        #[arg(long, default_value_t = false)]
295        release: bool,
296        /// Optional project root directory to watch (defaults to current directory).
297        #[arg(long)]
298        path: Option<PathBuf>,
299        /// Optional output directory for built bundles.
300        #[arg(long)]
301        out: Option<PathBuf>,
302        /// Optional Cargo package name to rebuild on changes.
303        #[arg(long)]
304        package: Option<String>,
305        /// Shared dev server bind, poll interval, and smoke-run flags.
306        #[command(flatten)]
307        server: ServerBindArgs,
308        /// Enable live Dynamic WASM OTA manifest + `.wasm` hot-update endpoint (`--ota=false` disables).
309        #[arg(long, default_value_t = true, num_args = 0..=1, default_missing_value = "true")]
310        ota: bool,
311        /// Print the structured dev server plan without spawning processes.
312        #[arg(long, default_value_t = false)]
313        plan: bool,
314    },
315    /// Manages the Hyperlane HTTP + SSE dynamic update server and atomic local release store (`serve`, `stage`, `publish`, `rollback`, `status`).
316    Update {
317        /// Dynamic update server or store management subcommand.
318        #[command(subcommand)]
319        action: UpdateAction,
320    },
321    /// Builds or live-serves a static documentation site from all `.md` files in a project.
322    Docs {
323        /// Optional `build` or `dev` subcommand (defaults to building all project `.md` files).
324        #[command(subcommand)]
325        action: Option<DocsAction>,
326        /// Shared source, output, title, and base URL flags.
327        #[command(flatten)]
328        build: DocsBuildArgs,
329        /// Enable live watch and SSE hot-reload dev server directly from `euv docs --watch`.
330        #[arg(short = 'w', long, default_value_t = false)]
331        watch: bool,
332        /// Shared dev server bind, poll interval, and smoke-run flags when `--watch` is active.
333        #[command(flatten)]
334        server: ServerBindArgs,
335    },
336    /// Builds native, terminal, wearable, HarmonyOS, Mini-Program, QuickApp, or Web bundles for one or all targets.
337    Build {
338        /// Target platform (or `all`).
339        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
340        target: TargetArg,
341        /// Optional HarmonyOS device form factor (`phone`, `tablet`, `pc`, `foldable`, `tv`, `car`, `wearable`).
342        #[arg(long, value_enum, default_value_t = HarmonyFormFactorArg::Phone)]
343        form_factor: HarmonyFormFactorArg,
344        /// Rendering pipeline mode default.
345        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
346        render: RenderArg,
347        /// Enable release optimization profile.
348        #[arg(long, default_value_t = false)]
349        release: bool,
350        /// Print structured JSON build plans without executing.
351        #[arg(long, default_value_t = false)]
352        plan: bool,
353    },
354    /// Checks Rust compilation across one or all cross-platform targets.
355    Check {
356        /// Check all supported platform targets in sequence.
357        #[arg(long, default_value_t = false)]
358        all_targets: bool,
359        /// Single target to check when `--all-targets` is omitted.
360        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
361        target: TargetArg,
362        /// Optional Cargo package name to check.
363        #[arg(long)]
364        package: Option<String>,
365        /// Print the planned commands without running Cargo.
366        #[arg(long, default_value_t = false)]
367        plan: bool,
368    },
369    /// Runs unified `crate-cli` text/Rust formatting first, then normalizes indentation inside all `euv` macro blocks (`view!`, `style!`, etc.).
370    Fmt {
371        /// Verify formatting without modifying files.
372        #[arg(long, default_value_t = false)]
373        check: bool,
374        /// Optional root directory or file path (defaults to current directory).
375        #[arg(long)]
376        path: Option<PathBuf>,
377        /// Format only `euv` procedural macro bodies without invoking `crate-cli` or `cargo fmt`.
378        #[arg(long, default_value_t = false)]
379        macros_only: bool,
380    },
381    /// Inspects installed Rust targets, SDKs, and cross-platform tooling readiness.
382    Doctor {
383        /// Emit machine-readable JSON output.
384        #[arg(long, default_value_t = false)]
385        json: bool,
386    },
387    /// Scaffolds a new cross-platform euv native project.
388    New {
389        /// Name of the new project directory and crate.
390        name: String,
391        /// Optional parent directory (defaults to current working directory).
392        #[arg(long)]
393        path: Option<PathBuf>,
394    },
395}