Skip to main content

euv_cli/args/
enum.rs

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