zenith_cli/cli/render.rs
1//! Argument types for `zenith render`.
2
3use clap::Args;
4use std::path::PathBuf;
5
6/// Arguments for `zenith render`.
7#[derive(Debug, Args)]
8#[command(
9 after_help = "At least one of --scene, --png, --pdf, or --all-pages is required.\n\n\
10EXAMPLES:\n \
11zenith render poster.zen --png out.png\n \
12zenith render book.zen --all-pages sheet/ # one PNG per page\n \
13zenith render book.zen --pdf book.pdf # print-ready vector PDF"
14)]
15pub struct RenderArgs {
16 /// Path to the `.zen` document.
17 pub path: PathBuf,
18
19 /// Write the compiled scene display-list JSON to this path.
20 #[arg(long, value_name = "OUT")]
21 pub scene: Option<PathBuf>,
22
23 /// Write the rendered PNG to this path.
24 #[arg(long, value_name = "OUT")]
25 pub png: Option<PathBuf>,
26
27 /// Write a vector PDF (with print boxes + DeviceCMYK) to this path.
28 #[arg(long, value_name = "OUT")]
29 pub pdf: Option<PathBuf>,
30
31 /// Embed whole font programs in the PDF instead of subsetting to used glyphs.
32 ///
33 /// PDF text is always selectable and searchable; this only trades a larger
34 /// file for embedding the complete face (default: subset for small files).
35 #[arg(long)]
36 pub embed_full_fonts: bool,
37
38 /// 1-based page number to render; for `--pdf`, the default renders all pages.
39 ///
40 /// Without `--page`, single-output flags (`--scene`/`--png`) render page 1,
41 /// while `--pdf` renders every page into one multi-page PDF. Passing
42 /// `--page N` selects exactly that page for all outputs.
43 #[arg(long, value_name = "N")]
44 pub page: Option<usize>,
45
46 /// Render every page to `<DIR>/page-<N>.png` (1-based) instead of a single page.
47 #[arg(long, value_name = "DIR")]
48 pub all_pages: Option<PathBuf>,
49
50 /// Render two facing pages side by side as a single PNG, e.g. `--spread 10-11`
51 /// (1-based page numbers; A on the left, B on the right). Requires `--png`.
52 #[arg(long, value_name = "A-B")]
53 pub spread: Option<String>,
54
55 /// Override the spread gutter in pixels (default: the document's spread-gutter, or 0).
56 /// Only used when `--spread` is set.
57 #[arg(long, value_name = "PX")]
58 pub gutter: Option<u32>,
59
60 /// Verify each image asset's bytes against its declared `sha256` and fail on mismatch.
61 #[arg(long)]
62 pub locked: bool,
63
64 /// Emit machine-readable JSON (diagnostics + output path) to stdout.
65 #[arg(long)]
66 pub json: bool,
67
68 /// Suppress a diagnostic code (downgrade Warning/Advisory to nothing).
69 ///
70 /// Repeatable. Overrides the document's in-file `diagnostics` block and any
71 /// global/local config policy for this code.
72 #[arg(long = "allow", value_name = "CODE", action = clap::ArgAction::Append)]
73 pub allow: Vec<String>,
74
75 /// Force a diagnostic code to Warning severity.
76 ///
77 /// Repeatable. Overrides the document's in-file `diagnostics` block and any
78 /// global/local config policy for this code.
79 #[arg(long = "warn", value_name = "CODE", action = clap::ArgAction::Append)]
80 pub warn: Vec<String>,
81
82 /// Elevate a diagnostic code to a blocking Error (CI gate).
83 ///
84 /// Repeatable. Overrides the document's in-file `diagnostics` block and any
85 /// global/local config policy for this code.
86 #[arg(long = "deny", value_name = "CODE", action = clap::ArgAction::Append)]
87 pub deny: Vec<String>,
88
89 /// Path to a JSON object/array or CSV file supplying values for
90 /// `(data)"field.path"` references. JSON nested keys flatten to dot-paths
91 /// (`{"a":{"b":1}}` → `"a.b"`); a JSON array uses the first element. CSV
92 /// header row gives field names; the first data row supplies values.
93 /// Produces a SINGLE render bound to the first object/row; for BATCH output
94 /// (one PNG per CSV row with a provenance manifest) use `zenith merge` instead.
95 #[arg(long, value_name = "FILE")]
96 pub data: Option<PathBuf>,
97}