Skip to main content

euv_cli/args/
enum.rs

1use super::*;
2
3/// CLI target selector covering all seven 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    /// Current host native target.
21    Native,
22    /// Every supported euv platform.
23    All,
24}
25
26/// CLI render pipeline mode selector.
27#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
28pub enum RenderArg {
29    /// Automatically prefer hardware GPU with software fallback.
30    Auto,
31    /// Deterministic software CPU rasterizer.
32    Software,
33    /// Native GPU instanced pipeline.
34    Hardware,
35    /// Hybrid CPU vector + GPU texture compositor.
36    Hybrid,
37}
38
39/// Target mode for the `euv dev` hot-reload and OTA development server.
40#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
41pub enum DevTargetArg {
42    /// Build and live-reload all project Markdown documentation pages.
43    Docs,
44    /// Build and live-reload WebAssembly zero-JS bundles plus Dynamic WASM OTA feed.
45    Web,
46    /// Watch Rust sources, rebuild, hot-restart the native app, and serve Dynamic WASM OTA updates.
47    Native,
48}
49
50/// Subcommands under `euv docs` for building or live-serving project Markdown documentation.
51#[derive(Clone, Debug, Eq, PartialEq, Subcommand)]
52pub enum DocsAction {
53    /// Builds all Markdown files under a project or docs directory into a static site.
54    Build {
55        /// Shared source, output, title, and base URL flags.
56        #[command(flatten)]
57        build: DocsBuildArgs,
58    },
59    /// Builds and serves Markdown documentation with live file-watching and SSE hot reload.
60    Dev {
61        /// Shared source, output, title, and base URL flags.
62        #[command(flatten)]
63        build: DocsBuildArgs,
64        /// Shared dev server bind, poll interval, and smoke-run flags.
65        #[command(flatten)]
66        server: ServerBindArgs,
67    },
68}
69
70/// Top-level `euv` CLI subcommands.
71#[derive(Clone, Debug, Eq, PartialEq, Subcommand)]
72pub enum Commands {
73    /// Runs an euv application for a target platform and render mode, with optional `--watch` hot reload.
74    Run {
75        /// Target platform to launch.
76        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
77        target: TargetArg,
78        /// Rendering pipeline mode.
79        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
80        render: RenderArg,
81        /// Build and run in release mode.
82        #[arg(long, default_value_t = false)]
83        release: bool,
84        /// Optional Cargo package name to run.
85        #[arg(long)]
86        package: Option<String>,
87        /// Enable file-watching hot reload and live OTA update serving.
88        #[arg(short = 'w', long, default_value_t = false)]
89        watch: bool,
90        /// HTTP hot-reload/OTA port when `--watch` is enabled.
91        #[arg(long, default_value_t = 8080)]
92        port: u16,
93        /// Print the execution plan without spawning Cargo.
94        #[arg(long, default_value_t = false)]
95        plan: bool,
96    },
97    /// Starts the hot-reload and Dynamic WASM OTA development server for Web, Native, or Docs.
98    Dev {
99        /// Development pipeline target (`web`, `native`, or `docs`).
100        #[arg(long, value_enum, default_value_t = DevTargetArg::Web)]
101        target: DevTargetArg,
102        /// Rendering pipeline mode default.
103        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
104        render: RenderArg,
105        /// Build and serve in release mode when rebuilding Web or Native targets.
106        #[arg(long, default_value_t = false)]
107        release: bool,
108        /// Optional project root directory to watch (defaults to current directory).
109        #[arg(long)]
110        path: Option<PathBuf>,
111        /// Optional output directory for built bundles.
112        #[arg(long)]
113        out: Option<PathBuf>,
114        /// Optional Cargo package name to rebuild on changes.
115        #[arg(long)]
116        package: Option<String>,
117        /// Shared dev server bind, poll interval, and smoke-run flags.
118        #[command(flatten)]
119        server: ServerBindArgs,
120        /// Enable live Dynamic WASM OTA manifest + `.wasm` hot-update endpoint (`--ota=false` disables).
121        #[arg(long, default_value_t = true, num_args = 0..=1, default_missing_value = "true")]
122        ota: bool,
123        /// Print the structured dev server plan without spawning processes.
124        #[arg(long, default_value_t = false)]
125        plan: bool,
126    },
127    /// Builds or live-serves a static documentation site from all `.md` files in a project.
128    Docs {
129        /// Optional `build` or `dev` subcommand (defaults to building all project `.md` files).
130        #[command(subcommand)]
131        action: Option<DocsAction>,
132        /// Shared source, output, title, and base URL flags.
133        #[command(flatten)]
134        build: DocsBuildArgs,
135        /// Enable live watch and SSE hot-reload dev server directly from `euv docs --watch`.
136        #[arg(short = 'w', long, default_value_t = false)]
137        watch: bool,
138        /// Shared dev server bind, poll interval, and smoke-run flags when `--watch` is active.
139        #[command(flatten)]
140        server: ServerBindArgs,
141    },
142    /// Builds native or Web bundles for one or all seven targets.
143    Build {
144        /// Target platform (or `all`).
145        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
146        target: TargetArg,
147        /// Rendering pipeline mode default.
148        #[arg(long, value_enum, default_value_t = RenderArg::Auto)]
149        render: RenderArg,
150        /// Enable release optimization profile.
151        #[arg(long, default_value_t = false)]
152        release: bool,
153        /// Print structured JSON build plans without executing.
154        #[arg(long, default_value_t = false)]
155        plan: bool,
156    },
157    /// Checks Rust compilation across one or all seven cross-platform targets.
158    Check {
159        /// Check all seven platform targets in sequence.
160        #[arg(long, default_value_t = false)]
161        all_targets: bool,
162        /// Single target to check when `--all-targets` is omitted.
163        #[arg(long, value_enum, default_value_t = TargetArg::Native)]
164        target: TargetArg,
165        /// Optional Cargo package name to check.
166        #[arg(long)]
167        package: Option<String>,
168        /// Print the planned commands without running Cargo.
169        #[arg(long, default_value_t = false)]
170        plan: bool,
171    },
172    /// Formats workspace Rust sources (`cargo fmt`) and normalizes indentation inside all `euv` macro blocks (`view!`, `style!`, etc.).
173    Fmt {
174        /// Verify formatting without modifying files.
175        #[arg(long, default_value_t = false)]
176        check: bool,
177        /// Optional root directory or `.rs` file path (defaults to current directory).
178        #[arg(long)]
179        path: Option<PathBuf>,
180        /// Format only `euv` procedural macro bodies without invoking `cargo fmt`.
181        #[arg(long, default_value_t = false)]
182        macros_only: bool,
183    },
184    /// Inspects installed Rust targets, SDKs, and cross-platform tooling readiness.
185    Doctor {
186        /// Emit machine-readable JSON output.
187        #[arg(long, default_value_t = false)]
188        json: bool,
189    },
190    /// Scaffolds a new cross-platform euv native project.
191    New {
192        /// Name of the new project directory and crate.
193        name: String,
194        /// Optional parent directory (defaults to current working directory).
195        #[arg(long)]
196        path: Option<PathBuf>,
197    },
198}