euv_cli/build/struct.rs
1use crate::*;
2
3/// euv CLI for real-time WASM compilation and hot-reload development server.
4///
5/// Defines the command-line interface with three sub-commands
6/// (`run` / `build` / `fmt`). All arguments after `--` are transparently
7/// forwarded to `wasm-pack build` without interpretation.
8#[derive(Clone, Data, Debug, New, Parser)]
9#[command(name = "euv")]
10#[command(about = "euv development server with live WASM compilation")]
11pub struct Cli {
12 /// The mode to run in: run (build + server), build (build only), or fmt (format)
13 #[command(subcommand)]
14 #[get(pub)]
15 #[get_mut(pub)]
16 #[set(pub)]
17 pub command: Mode,
18}
19
20/// euv-specific arguments combined with wasm-pack passthrough.
21///
22/// Only `--crate-path`, `--port`, `--www-dir`, `--index-html`, `--no-gitignore`, and `--dev`/`--release`/`--profiling`
23/// belong to euv; everything in `wasm_pack_args` is forwarded to `wasm-pack build` as-is.
24#[derive(Clone, Data, Debug, Parser)]
25pub struct ModeArgs {
26 /// Path to the Rust crate containing the WASM application
27 #[arg(short, long, default_value = ".")]
28 #[get(pub)]
29 #[get_mut(pub)]
30 #[set(pub)]
31 pub crate_path: PathBuf,
32 /// Port for the development server
33 #[arg(short, long, default_value_t = 80)]
34 #[get(pub, type(copy))]
35 #[get_mut(pub)]
36 #[set(pub)]
37 pub port: u16,
38 /// Directory name for static assets and generated HTML (relative to crate-path)
39 #[arg(long, default_value = "www")]
40 #[get(pub)]
41 #[get_mut(pub)]
42 #[set(pub)]
43 pub www_dir: String,
44 /// Path to a custom index.html template file.
45 /// When specified, uses this file instead of the built-in template.
46 /// The placeholders `__IMPORT_PATH__` and `__RELOAD_ROUTE__` will be replaced.
47 #[arg(long)]
48 #[get(pub)]
49 #[get_mut(pub)]
50 #[set(pub)]
51 pub index_html: Option<PathBuf>,
52 /// Create a development build. Enable debug info, and disable optimizations
53 #[arg(long)]
54 #[get(pub, type(copy))]
55 #[get_mut(pub)]
56 #[set(pub)]
57 pub dev: bool,
58 /// Create a release build. Enable optimizations and disable debug info
59 #[arg(long)]
60 #[get(pub, type(copy))]
61 #[get_mut(pub)]
62 #[set(pub)]
63 pub release: bool,
64 /// Create a profiling build. Enable optimizations and debug info
65 #[arg(long)]
66 #[get(pub, type(copy))]
67 #[get_mut(pub)]
68 #[set(pub)]
69 pub profiling: bool,
70 /// Remove the .gitignore file from the output directory after building
71 #[arg(long)]
72 #[get(pub, type(copy))]
73 #[get_mut(pub)]
74 #[set(pub)]
75 pub no_gitignore: bool,
76 /// Arguments transparently forwarded to `wasm-pack build`
77 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
78 #[get(pub)]
79 #[get_mut(pub)]
80 #[set(pub)]
81 pub wasm_pack_args: Vec<String>,
82}
83
84/// Arguments for the `fmt` subcommand.
85///
86/// Formats euv macro invocations (`html!`, `class!`, `vars!`, `watch!`)
87/// in Rust source files.
88#[derive(Clone, Data, Debug, New, Parser)]
89pub struct FmtArgs {
90 /// Path to the directory or file to format
91 #[arg(short, long, default_value = ".")]
92 #[get(pub)]
93 #[get_mut(pub)]
94 #[set(pub)]
95 pub path: PathBuf,
96 /// Check if formatting is needed without modifying files
97 #[arg(long, default_value_t = false)]
98 #[get(pub, type(copy))]
99 #[get_mut(pub)]
100 #[set(pub)]
101 pub check: bool,
102}