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        /// SSE keep-alive heartbeat interval in milliseconds.
163        #[arg(long, default_value_t = DEFAULT_UPDATE_HEARTBEAT_MS)]
164        heartbeat_ms: u64,
165        /// Background channel pointer watcher polling interval in milliseconds.
166        #[arg(long, default_value_t = DEFAULT_UPDATE_WATCH_POLL_MS)]
167        poll_ms: u64,
168        /// Validate store layout and server bind readiness then exit immediately.
169        #[arg(long, default_value_t = false)]
170        once: bool,
171        /// Print the structured server configuration without binding sockets.
172        #[arg(long, default_value_t = false)]
173        plan: bool,
174    },
175    /// Stages and SHA-256-verifies a release manifest and its blobs into `staging/<stage_id>/`.
176    Stage {
177        /// Local update store root directory.
178        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
179        store: PathBuf,
180        /// Logical project identifier.
181        #[arg(long)]
182        project: String,
183        /// Release channel name (e.g. `prod`).
184        #[arg(long)]
185        channel: String,
186        /// Unique stage identifier name.
187        #[arg(long)]
188        stage_id: String,
189        /// Path to the draft JSON `ReleaseManifest` file.
190        #[arg(long)]
191        manifest: PathBuf,
192        /// Directory containing built artifact blobs referenced by `manifest`.
193        #[arg(long)]
194        blobs_dir: PathBuf,
195    },
196    /// Atomically signs and publishes a staged release with a strictly monotonic sequence number.
197    Publish {
198        /// Local update store root directory.
199        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
200        store: PathBuf,
201        /// Logical project identifier.
202        #[arg(long)]
203        project: String,
204        /// Release channel name.
205        #[arg(long)]
206        channel: String,
207        /// Previously staged directory name under `staging/`.
208        #[arg(long)]
209        stage_id: String,
210        /// Offline HMAC-SHA256 signing secret (or provide `--signing-key-env`).
211        #[arg(long)]
212        signing_key: Option<String>,
213        /// Environment variable name holding the offline signing secret.
214        #[arg(long, default_value = ENV_UPDATE_SIGNING_KEY)]
215        signing_key_env: String,
216    },
217    /// Signs a NEW monotonic release pointing back to a historical release's verified blobs (never replaying old manifests).
218    Rollback {
219        /// Local update store root directory.
220        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
221        store: PathBuf,
222        /// Logical project identifier.
223        #[arg(long)]
224        project: String,
225        /// Release channel name.
226        #[arg(long)]
227        channel: String,
228        /// Historical release sequence whose verified artifacts should be restored.
229        #[arg(long)]
230        to_release: u64,
231        /// Offline HMAC-SHA256 signing secret (or provide `--signing-key-env`).
232        #[arg(long)]
233        signing_key: Option<String>,
234        /// Environment variable name holding the offline signing secret.
235        #[arg(long, default_value = ENV_UPDATE_SIGNING_KEY)]
236        signing_key_env: String,
237    },
238    /// Inspects active channel pointers, release counts, and content-addressed blob inventory in a local update store.
239    Status {
240        /// Local update store root directory.
241        #[arg(long, default_value = DEFAULT_UPDATE_STORE_DIR)]
242        store: PathBuf,
243        /// Optional project filter.
244        #[arg(long)]
245        project: Option<String>,
246        /// Optional channel filter.
247        #[arg(long)]
248        channel: Option<String>,
249    },
250}
251
252/// Top-level `euv` CLI subcommands.
253#[derive(Clone, Debug, Eq, PartialEq, Subcommand)]
254pub enum Commands {
255    /// Runs an euv application for a target platform and render mode, with optional `--watch` hot reload.
256    Run {
257        /// Target platform to launch.
258        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
259        target: TargetArg,
260        /// Optional HarmonyOS form factor (`phone`, `tablet`, `pc`, `foldable`, `tv`, `car`, `wearable`).
261        #[arg(long, value_enum, default_value_t = HarmonyFormFactorArg::Phone)]
262        form_factor: HarmonyFormFactorArg,
263        /// Rendering pipeline mode.
264        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
265        render: RenderArg,
266        /// Build and run in release mode.
267        #[arg(long, default_value_t = false)]
268        release: bool,
269        /// Optional Cargo package name to run.
270        #[arg(long)]
271        package: Option<String>,
272        /// Enable file-watching hot reload and live OTA update serving.
273        #[arg(short = 'w', long, default_value_t = false)]
274        watch: bool,
275        /// HTTP hot-reload/OTA port when `--watch` is enabled.
276        #[arg(long, default_value_t = 8080)]
277        port: u16,
278        /// Print the execution plan without spawning Cargo.
279        #[arg(long, default_value_t = false)]
280        plan: bool,
281    },
282    /// Starts the hot-reload and Dynamic WASM OTA development server for Web, Native, Docs, Terminal, Harmony, Wearable, MiniApp, or QuickApp.
283    Dev {
284        /// Development pipeline target (`web`, `native`, `docs`, `tui`, `cli`, `harmony`, `wearable`, `miniapp`, `quickapp`).
285        #[arg(long, value_enum, default_value_t = DevTargetArg::Web)]
286        target: DevTargetArg,
287        /// Rendering pipeline mode default.
288        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
289        render: RenderArg,
290        /// Build and serve in release mode when rebuilding Web or Native targets.
291        #[arg(long, default_value_t = false)]
292        release: bool,
293        /// Optional project root directory to watch (defaults to current directory).
294        #[arg(long)]
295        path: Option<PathBuf>,
296        /// Optional output directory for built bundles.
297        #[arg(long)]
298        out: Option<PathBuf>,
299        /// Optional Cargo package name to rebuild on changes.
300        #[arg(long)]
301        package: Option<String>,
302        /// Shared dev server bind, poll interval, and smoke-run flags.
303        #[command(flatten)]
304        server: ServerBindArgs,
305        /// Enable live Dynamic WASM OTA manifest + `.wasm` hot-update endpoint (`--ota=false` disables).
306        #[arg(long, default_value_t = true, num_args = 0..=1, default_missing_value = "true")]
307        ota: bool,
308        /// Print the structured dev server plan without spawning processes.
309        #[arg(long, default_value_t = false)]
310        plan: bool,
311    },
312    /// Manages the Hyperlane HTTP + SSE dynamic update server and atomic local release store (`serve`, `stage`, `publish`, `rollback`, `status`).
313    Update {
314        /// Dynamic update server or store management subcommand.
315        #[command(subcommand)]
316        action: UpdateAction,
317    },
318    /// Builds or live-serves a static documentation site from all `.md` files in a project.
319    Docs {
320        /// Optional `build` or `dev` subcommand (defaults to building all project `.md` files).
321        #[command(subcommand)]
322        action: Option<DocsAction>,
323        /// Shared source, output, title, and base URL flags.
324        #[command(flatten)]
325        build: DocsBuildArgs,
326        /// Enable live watch and SSE hot-reload dev server directly from `euv docs --watch`.
327        #[arg(short = 'w', long, default_value_t = false)]
328        watch: bool,
329        /// Shared dev server bind, poll interval, and smoke-run flags when `--watch` is active.
330        #[command(flatten)]
331        server: ServerBindArgs,
332    },
333    /// Builds native, terminal, wearable, HarmonyOS, Mini-Program, QuickApp, or Web bundles for one or all targets.
334    Build {
335        /// Target platform (or `all`).
336        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
337        target: TargetArg,
338        /// Optional HarmonyOS device form factor (`phone`, `tablet`, `pc`, `foldable`, `tv`, `car`, `wearable`).
339        #[arg(long, value_enum, default_value_t = HarmonyFormFactorArg::Phone)]
340        form_factor: HarmonyFormFactorArg,
341        /// Rendering pipeline mode default.
342        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
343        render: RenderArg,
344        /// Enable release optimization profile.
345        #[arg(long, default_value_t = false)]
346        release: bool,
347        /// Print structured JSON build plans without executing.
348        #[arg(long, default_value_t = false)]
349        plan: bool,
350    },
351    /// Checks Rust compilation across one or all cross-platform targets.
352    Check {
353        /// Check all supported platform targets in sequence.
354        #[arg(long, default_value_t = false)]
355        all_targets: bool,
356        /// Single target to check when `--all-targets` is omitted.
357        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
358        target: TargetArg,
359        /// Optional Cargo package name to check.
360        #[arg(long)]
361        package: Option<String>,
362        /// Print the planned commands without running Cargo.
363        #[arg(long, default_value_t = false)]
364        plan: bool,
365    },
366    /// Runs unified `crate-cli` text/Rust formatting first, then normalizes indentation inside all `euv` macro blocks (`view!`, `style!`, etc.).
367    Fmt {
368        /// Verify formatting without modifying files.
369        #[arg(long, default_value_t = false)]
370        check: bool,
371        /// Optional root directory or file path (defaults to current directory).
372        #[arg(long)]
373        path: Option<PathBuf>,
374        /// Format only `euv` procedural macro bodies without invoking `crate-cli` or `cargo fmt`.
375        #[arg(long, default_value_t = false)]
376        macros_only: bool,
377    },
378    /// Inspects installed Rust targets, SDKs, and cross-platform tooling readiness.
379    Doctor {
380        /// Emit machine-readable JSON output.
381        #[arg(long, default_value_t = false)]
382        json: bool,
383    },
384    /// Scaffolds a new cross-platform euv native project.
385    New {
386        /// Name of the new project directory and crate.
387        name: String,
388        /// Optional parent directory (defaults to current working directory).
389        #[arg(long)]
390        path: Option<PathBuf>,
391    },
392}