vertigo_cli/serve/serve_opts.rs
1use clap::Args;
2
3use crate::commons::models::CommonOpts;
4use crate::commons::parse_key_val;
5
6#[derive(Args, Clone, Debug)]
7pub struct ServeOpts {
8 #[clap(flatten)]
9 pub inner: ServeOptsInner,
10 #[clap(flatten)]
11 pub common: CommonOpts,
12}
13
14#[derive(Args, Clone, Debug)]
15pub struct ServeOptsInner {
16 #[arg(long, default_value_t = {"127.0.0.1".into()})]
17 pub host: String,
18 #[arg(long, default_value_t = {4444})]
19 pub port: u16,
20
21 /// sets up proxy: `--proxy /path=http://domain.com/path`
22 #[arg(long, value_parser = parse_key_val::<String, String>)]
23 pub proxy: Vec<(String, String)>,
24
25 /// Define a mount point for the app in public url.
26 ///
27 /// (For example an nginx's location in which proxy_pass to the app was defined)
28 #[arg(long, default_value_t = {"/".to_string()})]
29 pub mount_point: String,
30
31 /// Setting the parameters `--env api=http://domain.com/api --env api2=http://domain.com/api2`
32 #[arg(long, value_parser = parse_key_val::<String, String>)]
33 pub env: Vec<(String, String)>,
34
35 /// Whether to add `<link rel="preload">` tag to `<head>` to make the browser load WASM earlier
36 #[arg(long, default_value_t = {false})]
37 pub wasm_preload: bool,
38
39 /// Disable hydration on page load (will re-create DOM instead of claiming existing nodes from SSR)
40 #[arg(long, default_value_t = {false})]
41 pub disable_hydration: bool,
42
43 /// Origin for resolving relative fetch URLs during SSR: `--ssr-fetch-base http://127.0.0.1:8080`
44 ///
45 /// (default: this server's address)
46 #[arg(long)]
47 pub ssr_fetch_base: Option<String>,
48
49 /// Indent the server-rendered HTML, to read it in the page source
50 ///
51 /// (the indentation is whitespace between elements: until the app starts, it shows as gaps
52 /// between inline ones, which hydration then takes out)
53 #[arg(long, default_value_t = {false})]
54 pub pretty_html: bool,
55
56 /// Disable gzip/brotli/zstd compression of served responses
57 ///
58 /// (useful behind a proxy or CDN that already compresses)
59 #[arg(long, default_value_t = {false})]
60 pub disable_compression: bool,
61
62 /// Number of threads to use for processing requests
63 ///
64 /// (default: number of CPU cores, 2 for watch mode)
65 #[arg(long)]
66 pub threads: Option<usize>,
67}