Shared macro definitions imported by cli-spec.adoc and each standalone
binary CLI spec. Not a driver file — contains only %def blocks that
produce no output themselves.
Shared renderers
%redef(render_rust_struct_chunk_option, chunk_name, field, rust_type, arg_attr, doc_block, doc_flag, doc_default, doc_descr, %{
// <<%(chunk_name)>>=
%(doc_block)
%if(%(arg_attr), %{ #[arg(%(arg_attr))]
%})
pub(crate) %(field): %(rust_type),
// @
%})
%redef(render_rust_enum_chunk_option, chunk_name, field, rust_type, arg_attr, doc_block, doc_flag, doc_default, doc_descr, %{
// <<%(chunk_name)>>=
%(doc_block)
%if(%(arg_attr), %{ #[arg(%(arg_attr))]
%})
%(field): %(rust_type),
// @
%})
%redef(render_doc_chunk_option, chunk_name, field, rust_type, arg_attr, doc_block, doc_flag, doc_default, doc_descr, %{
// <<%(chunk_name)>>=
| %(doc_flag) | %(doc_default) | %(doc_descr)
// @
%})
Shared args
%redef(macro_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = inputs,
rust_type = Vec<PathBuf>,
arg_attr = %{required = false%},
doc_block = %{ /// Input files (mutually exclusive with --dir)%},
doc_flag = %{`<INPUTS>...`%},
doc_default = %{ %},
doc_descr = %{Explicit files to process when `--dir` is not used.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = input_dir,
rust_type = PathBuf,
arg_attr = %{long, default_value = "."%},
doc_block = %{ /// Base directory prepended to every input path%},
doc_flag = %{`--input-dir <PATH>`%},
doc_default = %{`.`%},
doc_descr = %{Base directory prepended to every input path.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = sigil,
rust_type = char,
arg_attr = %{long, default_value = "%"%},
doc_block = %{ /// Macro sigil%},
doc_flag = %{`--sigil <CHAR>`%},
doc_default = %{`%`%},
doc_descr = %{Macro sigil character.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = no_macros,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Skip macro expansion and feed source files directly to the tangle pass.
/// Use this when the source files contain no macros and the sigil
/// character would collide with literal text (e.g. %, ^ in Rust or shell).%},
doc_flag = %{`--no-macros`%},
doc_default = %{off%},
doc_descr = %{Skip macro expansion and feed source files directly to the tangle pass.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = macro_prelude,
rust_type = Vec<PathBuf>,
arg_attr = %{long = "macro-prelude"%},
doc_block = %{ /// Prelude file evaluated before source files in macro-enabled mode.
/// Repeatable. Intended for markup prelude files such as prelude/asciidoc.wvb.%},
doc_flag = %{`--macro-prelude <PATH>`%},
doc_default = %{none%},
doc_descr = %{Evaluate a macro prelude before source files.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = expanded_ext,
rust_type = Option<String>,
arg_attr = %{long = "expanded-ext"%},
doc_block = %{ /// Extension assigned to macro-expanded virtual documents before tangling.
/// Example: --expanded-ext adoc lets .wvb sources expand to AsciiDoc.%},
doc_flag = %{`--expanded-ext <EXT>`%},
doc_default = %{input extension%},
doc_descr = %{Parse macro-expanded virtual documents as this extension.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = expanded_adoc_dir,
rust_type = PathBuf,
arg_attr = %{long = "expanded-adoc-dir", default_value = "expanded-adoc"%},
doc_block = %{ /// Directory for macro-expanded .adoc intermediate documents.
/// Normal mode writes these files and then tangles them; --macro-only stops there.%},
doc_flag = %{`--expanded-adoc-dir <PATH>`%},
doc_default = %{`expanded-adoc`%},
doc_descr = %{Directory for macro-expanded AsciiDoc intermediate documents.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = expanded_md_dir,
rust_type = PathBuf,
arg_attr = %{long = "expanded-md-dir", default_value = "expanded-md"%},
doc_block = %{ /// Directory for macro-expanded .md intermediate documents.
/// Separate from .adoc so both products can be generated and inspected.%},
doc_flag = %{`--expanded-md-dir <PATH>`%},
doc_default = %{`expanded-md`%},
doc_descr = %{Directory for macro-expanded Markdown intermediate documents.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = macro_only,
rust_type = bool,
arg_attr = %{long = "macro-only"%},
doc_block = %{ /// Stop after macro expansion after writing expanded documents.
/// This is the first-stage expansion pass for .wvb authoring sources.%},
doc_flag = %{`--macro-only`%},
doc_default = %{off%},
doc_descr = %{Write macro-expanded documents and skip tangling.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = include,
rust_type = String,
arg_attr = %{long, default_value = "."%},
doc_block = %{ /// Include paths for %include/%import (colon-separated on Unix)%},
doc_flag = %{`--include <PATHS>`%},
doc_default = %{`.`%},
doc_descr = %{Include search paths for `%include` and `%import` (colon-separated on Unix).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = db,
rust_type = PathBuf,
arg_attr = %{long, default_value = "weaveback.db"%},
doc_block = %{ /// Path to the weaveback database [default: weaveback.db in current directory]%},
doc_flag = %{`--db <PATH>`%},
doc_default = %{`weaveback.db`%},
doc_descr = %{Path to the source-map database.%},
)
%})
%redef(debug_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = dump_expanded,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Print macro-expanded text to stderr before noweb processing%},
doc_flag = %{`--dump-expanded`%},
doc_default = %{off%},
doc_descr = %{Print macro-expanded text to stderr before noweb processing.%},
)
%})
%redef(tangle_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = gen_dir,
rust_type = PathBuf,
arg_attr = %{long = "gen", default_value = "gen"%},
doc_block = %{ /// Base directory for generated output files%},
doc_flag = %{`--gen <PATH>`%},
doc_default = %{`gen`%},
doc_descr = %{Base directory for generated output files.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = open_delim,
rust_type = String,
arg_attr = %{long, default_value = "<["%},
doc_block = %{ /// Chunk open delimiter%},
doc_flag = %{`--open-delim <STR>`%},
doc_default = %{`<[`%},
doc_descr = %{Chunk-open delimiter.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = close_delim,
rust_type = String,
arg_attr = %{long, default_value = "]>"%},
doc_block = %{ /// Chunk close delimiter%},
doc_flag = %{`--close-delim <STR>`%},
doc_default = %{`]>`%},
doc_descr = %{Chunk-close delimiter.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = chunk_end,
rust_type = String,
arg_attr = %{long, default_value = "@"%},
doc_block = %{ /// Chunk end marker%},
doc_flag = %{`--chunk-end <STR>`%},
doc_default = %{`@`%},
doc_descr = %{End-of-chunk marker.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = comment_markers,
rust_type = String,
arg_attr = %{long, default_value = "#,//"%},
doc_block = %{ /// Comment markers recognised before chunk delimiters (comma-separated)%},
doc_flag = %{`--comment-markers <STR>`%},
doc_default = %{`#,//`%},
doc_descr = %{Comment prefixes recognised before chunk delimiters (comma-separated).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = formatter,
rust_type = Vec<String>,
arg_attr = %{long, value_name = "EXT=CMD"%},
doc_block = %{ /// Formatter command per output file extension, e.g. --formatter rs=rustfmt%},
doc_flag = %{`--formatter <EXT=CMD>`%},
doc_default = %{ %},
doc_descr = %{Run a formatter after writing each file, e.g. `rs=rustfmt`; repeatable.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = force_generated,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Overwrite generated files even if they differ from the stored baseline.
/// Intended for explicit recovery or regeneration workflows.%},
doc_flag = %{`--force-generated`%},
doc_default = %{off%},
doc_descr = %{Overwrite generated files even if they differ from the stored baseline.%},
)
%})
%redef(directory_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = directory,
rust_type = Option<PathBuf>,
arg_attr = %{long = "dir", conflicts_with = "inputs"%},
doc_block = %{ /// Discover and process driver files under this directory.
/// A driver is any file (matching --ext) not referenced by a %include() in another such file.
/// Mutually exclusive with positional input files.%},
doc_flag = %{`--dir <DIR>`%},
doc_default = %{ %},
doc_descr = %{Auto-discover driver files; mutually exclusive with positional inputs.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = ext,
rust_type = Vec<String>,
arg_attr = %{long, default_value = "md"%},
doc_block = %{ /// File extension(s) to scan in --dir mode (can be repeated).
/// Default: md. Example: --ext adoc --ext md to scan both.%},
doc_flag = %{`--ext <EXT>`%},
doc_default = %{`md`%},
doc_descr = %{File extension to scan in `--dir` mode; repeatable.%},
)
%})
%redef(build_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = depfile,
rust_type = Option<PathBuf>,
arg_attr = %{long%},
doc_block = %{ /// Write a Makefile depfile listing every source file read.
/// In --dir mode the depfile lists ALL matching files found so that
/// adding a new file triggers a rebuild.%},
doc_flag = %{`--depfile <PATH>`%},
doc_default = %{ %},
doc_descr = %{Write a Makefile depfile listing every source file read.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = stamp,
rust_type = Option<PathBuf>,
arg_attr = %{long%},
doc_block = %{ /// Touch this file on success (build-system stamp).%},
doc_flag = %{`--stamp <PATH>`%},
doc_default = %{ %},
doc_descr = %{Touch this file on success (build-system stamp).%},
)
%})
%redef(hidden_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = no_fts,
rust_type = bool,
arg_attr = %{long, hide = true%},
doc_block = %{ /// Skip rebuilding the prose full-text search index after this run.
/// Used internally by `wb-tangle` to avoid concurrent FTS rebuilds;
/// the tangle command rebuilds the index once after all passes complete.%},
doc_flag = %{hidden%},
doc_default = %{hidden%},
doc_descr = %{hidden%},
)
%})
%redef(security_arg_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = allow_env,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Allow %env(NAME) to read environment variables.
/// Disabled by default to prevent templates from silently reading secrets.%},
doc_flag = %{`--allow-env`%},
doc_default = %{off%},
doc_descr = %{Enable `%env(NAME)` (disabled by default to protect secrets).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = allow_home,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Allow @file ~/… chunks to write outside the gen/ directory.%},
doc_flag = %{`--allow-home`%},
doc_default = %{off%},
doc_descr = %{Allow `@file ~/…` chunks to write outside the `gen/` sandbox.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = strict,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Treat references to undefined chunks as fatal errors (default: expand to nothing).%},
doc_flag = %{`--strict`%},
doc_default = %{off%},
doc_descr = %{Treat references to undefined chunks as fatal errors (default: silently expand to nothing).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = dry_run,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Print output paths without writing anything.%},
doc_flag = %{`--dry-run`%},
doc_default = %{off%},
doc_descr = %{Print output paths without writing anything.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = warn_unused,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Warn about chunks that are defined but never referenced by any @file chunk.
/// Suppressed by default to keep output clean when large libraries of helper
/// chunks are defined speculatively.%},
doc_flag = %{`--warn-unused`%},
doc_default = %{off%},
doc_descr = %{Warn about named chunks that are defined but never referenced by any `@file` chunk; suppressed by default.%},
)
%})
Subcommand option groups
%redef(tangle_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = config,
rust_type = std::path::PathBuf,
arg_attr = %{long, default_value = "weaveback.toml"%},
doc_block = %{ /// Path to the tangle config file%},
doc_flag = %{`--config <PATH>`%},
doc_default = %{`weaveback.toml`%},
doc_descr = %{Path to the tangle config file.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = force_generated,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Overwrite generated files even if they differ from the stored baseline.
/// Use this only when the literate source is the authoritative state.%},
doc_flag = %{`--force-generated`%},
doc_default = %{off%},
doc_descr = %{Overwrite generated files even if they differ from the stored baseline.%},
)
%})
%redef(tag_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = config,
rust_type = std::path::PathBuf,
arg_attr = %{long, default_value = "weaveback.toml"%},
doc_block = %{ /// Path to the tangle config file (reads [tags] section)%},
doc_flag = %{`--config <PATH>`%},
doc_default = %{`weaveback.toml`%},
doc_descr = %{Path to the tangle config file (reads `[tags]`).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = backend,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Override backend (anthropic/gemini/openai/ollama)%},
doc_flag = %{`--backend <BACKEND>`%},
doc_default = %{ %},
doc_descr = %{Override backend (`anthropic`, `gemini`, `openai`, `ollama`).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = model,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Override model name%},
doc_flag = %{`--model <MODEL>`%},
doc_default = %{ %},
doc_descr = %{Override model name.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = endpoint,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Override API endpoint (for ollama / openai-compatible)%},
doc_flag = %{`--endpoint <URL>`%},
doc_default = %{ %},
doc_descr = %{Override API endpoint (for ollama or openai-compatible backends).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = batch_size,
rust_type = Option<usize>,
arg_attr = %{long%},
doc_block = %{ /// Override blocks per LLM request%},
doc_flag = %{`--batch-size <N>`%},
doc_default = %{ %},
doc_descr = %{Override blocks per LLM request.%},
)
%})
%redef(apply_back_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = files,
rust_type = Vec<String>,
arg_attr =,
doc_block = %{ /// Relative paths within gen/ to process (default: all modified files)%},
doc_flag = %{`<FILES>...`%},
doc_default = %{ %},
doc_descr = %{Relative paths within `gen/` to process (default: all modified files).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = dry_run,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Show what would change without writing anything%},
doc_flag = %{`--dry-run`%},
doc_default = %{off%},
doc_descr = %{Show what would change without writing anything.%},
)
%})
%redef(graph_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = chunk,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Restrict to the subgraph reachable from this chunk%},
doc_flag = %{`--chunk <CHUNK>`%},
doc_default = %{ %},
doc_descr = %{Restrict to the subgraph reachable from this chunk.%},
)
%})
%redef(search_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = query,
rust_type = String,
arg_attr =,
doc_block = %{ /// Search query (FTS5 syntax: AND, OR, NOT, phrase "...", prefix foo*)%},
doc_flag = %{`<QUERY>`%},
doc_default = %{ %},
doc_descr = %{Search query (FTS5 syntax: `AND`, `OR`, `NOT`, phrase `"..."`, prefix `foo*`).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = limit,
rust_type = usize,
arg_attr = %{long, default_value = "10"%},
doc_block = %{ /// Maximum number of results to show%},
doc_flag = %{`--limit <N>`%},
doc_default = %{`10`%},
doc_descr = %{Maximum number of results to show.%},
)
%})
%redef(attribute_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = scan_stdin,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Read plain text from stdin, extract FILE:LINE[:COL] locations, and attribute them%},
doc_flag = %{`--scan-stdin`%},
doc_default = %{off%},
doc_descr = %{Read plain text from stdin, extract `FILE:LINE[:COL]` locations, and attribute them.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = summary,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Emit grouped source-of-truth summary JSON instead of a flat result array%},
doc_flag = %{`--summary`%},
doc_default = %{off%},
doc_descr = %{Emit grouped source-of-truth summary JSON instead of a flat result array.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = locations,
rust_type = Vec<String>,
arg_attr =,
doc_block = %{ /// One or more generated locations in FILE:LINE or FILE:LINE:COL form%},
doc_flag = %{`<LOCATIONS>...`%},
doc_default = %{ %},
doc_descr = %{One or more generated locations in `FILE:LINE` or `FILE:LINE:COL` form.%},
)
%})
%redef(cargo_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = diagnostics_only,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Emit only compiler messages and the final source-of-truth summary, not Cargo artifact chatter%},
doc_flag = %{`--diagnostics-only`%},
doc_default = %{off%},
doc_descr = %{Emit only compiler messages and the final source-of-truth summary.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = args,
rust_type = Vec<String>,
arg_attr = %{trailing_var_arg = true, allow_hyphen_values = true%},
doc_block = %{ /// Cargo subcommand and arguments, passed through after `wb-query cargo`%},
doc_flag = %{`[ARGS]...`%},
doc_default = %{ %},
doc_descr = %{Cargo subcommand and arguments, passed through after `wb-query cargo`.%},
)
%})
%redef(lint_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = paths,
rust_type = Vec<PathBuf>,
arg_attr =,
doc_block = %{ /// Files or directories to lint (default: current tree)%},
doc_flag = %{`<PATHS>...`%},
doc_default = %{current tree%},
doc_descr = %{Files or directories to lint (default: current tree).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = strict,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Treat violations as errors%},
doc_flag = %{`--strict`%},
doc_default = %{off%},
doc_descr = %{Treat violations as errors.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = rule,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Restrict linting to one rule%},
doc_flag = %{`--rule <RULE>`%},
doc_default = %{all%},
doc_descr = %{Restrict linting to one rule.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = json,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Emit structured JSON instead of human-readable text%},
doc_flag = %{`--json`%},
doc_default = %{off%},
doc_descr = %{Emit structured JSON instead of human-readable text.%},
)
%})
%redef(coverage_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = summary,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Print a concise human summary ranked by missed lines instead of full JSON%},
doc_flag = %{`--summary`%},
doc_default = %{off%},
doc_descr = %{Print a concise human summary ranked by missed lines instead of full JSON.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = top_sources,
rust_type = usize,
arg_attr = %{long, default_value = "10"%},
doc_block = %{ /// Maximum number of source files to show in summary mode%},
doc_flag = %{`--top-sources <N>`%},
doc_default = %{`10`%},
doc_descr = %{Maximum number of source files to show in summary mode.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = top_sections,
rust_type = usize,
arg_attr = %{long, default_value = "3"%},
doc_block = %{ /// Maximum number of sections to show per source file in summary mode%},
doc_flag = %{`--top-sections <N>`%},
doc_default = %{`3`%},
doc_descr = %{Maximum number of sections to show per source file in summary mode.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = explain_unattributed,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// For each unattributed file show the unmapped line ranges with source content%},
doc_flag = %{`--explain-unattributed`%},
doc_default = %{off%},
doc_descr = %{For each unattributed file, print the unmapped line ranges with the actual source content so you can see which code lacks noweb entries.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = lcov_file,
rust_type = PathBuf,
arg_attr =,
doc_block = %{ /// Path to an LCOV tracefile, typically `lcov.info` from `cargo llvm-cov --lcov`%},
doc_flag = %{`<LCOV>`%},
doc_default = %{ %},
doc_descr = %{Path to an LCOV tracefile, typically `lcov.info` from `cargo llvm-cov --lcov`.%},
)
%})
%redef(tags_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = file,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Filter to a single source file (plain relative path)%},
doc_flag = %{`--file <PATH>`%},
doc_default = %{ %},
doc_descr = %{Filter to a single source file (plain relative path).%},
)
%})
%redef(lsp_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = lsp_cmd,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Manual override for the LSP command (e.g. "nimlsp")%},
doc_flag = %{`--lsp-cmd <CMD>`%},
doc_default = %{(auto)%},
doc_descr = %{Manual override for LSP command (e.g. `nimlsp`).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = lsp_lang,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// Manual override for the language ID (e.g. "nim")%},
doc_flag = %{`--lsp-lang <ID>`%},
doc_default = %{(auto)%},
doc_descr = %{Manual override for language ID (e.g. `nim`).%},
)
%})
%redef(serve_command_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = port,
rust_type = u16,
arg_attr = %{long, default_value = "7779"%},
doc_block = %{ /// TCP port to listen on%},
doc_flag = %{`--port <N>`%},
doc_default = %{`7779`%},
doc_descr = %{TCP port to listen on.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = html,
rust_type = Option<PathBuf>,
arg_attr = %{long%},
doc_block = %{ /// Directory to serve (default: <project-root>/docs/html)%},
doc_flag = %{`--html <PATH>`%},
doc_default = %{`<root>/docs/html`%},
doc_descr = %{Directory to serve.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = open_delim,
rust_type = String,
arg_attr = %{long, default_value = "<["%},
doc_block = %{ /// Chunk open delimiter for the tangle oracle (default: <[)%},
doc_flag = %{`--open-delim <STR>`%},
doc_default = %{`<[`%},
doc_descr = %{Chunk-open delimiter for the tangle oracle.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = close_delim,
rust_type = String,
arg_attr = %{long, default_value = "]>"%},
doc_block = %{ /// Chunk close delimiter for the tangle oracle (default: ]>)%},
doc_flag = %{`--close-delim <STR>`%},
doc_default = %{`]>`%},
doc_descr = %{Chunk-close delimiter for the tangle oracle.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = chunk_end,
rust_type = String,
arg_attr = %{long, default_value = "@@"%},
doc_block = %{ /// Chunk-end marker for the tangle oracle (default: @@)%},
doc_flag = %{`--chunk-end <STR>`%},
doc_default = %{`@@`%},
doc_descr = %{Chunk-end marker for the tangle oracle.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = comment_markers,
rust_type = String,
arg_attr = %{long, default_value = "//"%},
doc_block = %{ /// Comment markers for the tangle oracle (comma-separated, default: //)%},
doc_flag = %{`--comment-markers <STR>`%},
doc_default = %{`//`%},
doc_descr = %{Comment prefixes for the oracle (comma-separated).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = ai_backend,
rust_type = String,
arg_attr = %{long, default_value = "claude-cli"%},
doc_block = %{ /// AI backend for /__ai: "claude-cli" (default), "anthropic", "gemini", "ollama", "openai"%},
doc_flag = %{`--ai-backend <MODE>`%},
doc_default = %{`claude-cli`%},
doc_descr = %{AI backend for `/__ai`: `claude-cli`, `anthropic`, `gemini`, `ollama`, or `openai`.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = ai_model,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// AI model name (e.g. "claude-3-5-sonnet-20240620", "gemini-1.5-pro", "llama3")%},
doc_flag = %{`--ai-model <STR>`%},
doc_default = %{(default)%},
doc_descr = %{AI model name (e.g. `gemini-1.5-pro`, `llama3`, `gpt-4o`).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = ai_endpoint,
rust_type = Option<String>,
arg_attr = %{long%},
doc_block = %{ /// AI API endpoint / base URL (for ollama or openai-compatible backends)%},
doc_flag = %{`--ai-endpoint <URL>`%},
doc_default = %{(default)%},
doc_descr = %{Base URL for `ollama` or `openai` backends.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = watch,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Watch .adoc and theme sources; tangle + re-render docs on each change%},
doc_flag = %{`--watch`%},
doc_default = %{off%},
doc_descr = %{Watch `.adoc` and theme sources; tangle + re-render docs on each change.%},
)
%})
Standalone binary option groups
Reusable groups for standalone binaries that lack a global Args struct.
%redef(eval_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = sigil,
rust_type = char,
arg_attr = %{long, default_value = "%"%},
doc_block = %{ /// Macro sigil character%},
doc_flag = %{`--sigil <CHAR>`%},
doc_default = %{`%`%},
doc_descr = %{Macro sigil character.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = include,
rust_type = String,
arg_attr = %{long, default_value = "."%},
doc_block = %{ /// Include paths for %include/%import (colon-separated on Unix)%},
doc_flag = %{`--include <PATHS>`%},
doc_default = %{`.`%},
doc_descr = %{Include search paths for `%include` and `%import`.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = allow_env,
rust_type = bool,
arg_attr = %{long%},
doc_block = %{ /// Allow %env(NAME) to read environment variables%},
doc_flag = %{`--allow-env`%},
doc_default = %{off%},
doc_descr = %{Enable `%env(NAME)` (disabled by default to protect secrets).%},
)
%})
%redef(tangle_delim_options, chunk_name, %{
%emit_option(
chunk_name = %(chunk_name),
field = gen_dir,
rust_type = PathBuf,
arg_attr = %{long = "gen", default_value = "gen"%},
doc_block = %{ /// Base directory for generated output files%},
doc_flag = %{`--gen <PATH>`%},
doc_default = %{`gen`%},
doc_descr = %{Base directory for generated output files.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = open_delim,
rust_type = String,
arg_attr = %{long, default_value = "<["%},
doc_block = %{ /// Chunk open delimiter%},
doc_flag = %{`--open-delim <STR>`%},
doc_default = %{`<[`%},
doc_descr = %{Chunk-open delimiter.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = close_delim,
rust_type = String,
arg_attr = %{long, default_value = "]>"%},
doc_block = %{ /// Chunk close delimiter%},
doc_flag = %{`--close-delim <STR>`%},
doc_default = %{`]>`%},
doc_descr = %{Chunk-close delimiter.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = chunk_end,
rust_type = String,
arg_attr = %{long, default_value = "@"%},
doc_block = %{ /// Chunk end marker%},
doc_flag = %{`--chunk-end <STR>`%},
doc_default = %{`@`%},
doc_descr = %{End-of-chunk marker.%},
)
%emit_option(
chunk_name = %(chunk_name),
field = comment_markers,
rust_type = String,
arg_attr = %{long, default_value = "#,//"%},
doc_block = %{ /// Comment markers recognised before chunk delimiters (comma-separated)%},
doc_flag = %{`--comment-markers <STR>`%},
doc_default = %{`#,//`%},
doc_descr = %{Comment prefixes recognised before chunk delimiters (comma-separated).%},
)
%emit_option(
chunk_name = %(chunk_name),
field = formatter,
rust_type = Vec<String>,
arg_attr = %{long, value_name = "EXT=CMD"%},
doc_block = %{ /// Formatter command per output file extension, e.g. --formatter rs=rustfmt%},
doc_flag = %{`--formatter <EXT=CMD>`%},
doc_default = %{ %},
doc_descr = %{Run a formatter after writing each file, e.g. `rs=rustfmt`; repeatable.%},
)
%})