use std::ffi::OsString;
use std::panic::AssertUnwindSafe;
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use miette::Result;
mod build;
mod fmt;
mod input;
mod lint;
mod lint_sink;
mod output;
mod watch;
mod write;
use build::{
build_runtime_vars, emit_duplicate_var_warnings, exit_code, parse_key_value, resolve_input,
run_build, BuildArgs, RuntimeVarArgs,
};
// ── CLI entry point ───────────────────────────────────────────────────────────
#[derive(Parser)]
#[command(
name = "mds",
about = "MDS (Markdown Script) compiler",
long_about = "MDS (Markdown Script) compiler — composable LLM prompt templates\n\nCompile .mds template files into Markdown. Use variables, loops,\nconditionals, functions, and imports to build reusable prompts.\n\nQuick start:\n mds init Create a starter template\n mds build hello.mds Compile to hello.md\n mds build hello.mds -o - Compile to stdout\n mds build hello.mds -o out.md Compile to a specific file\n mds watch hello.mds Watch and recompile on save",
version
)]
struct Cli {
#[command(subcommand)]
command: Commands,
/// Suppress status and diagnostic output; errors always print; exit codes unaffected
#[arg(long, short = 'q', global = true)]
quiet: bool,
}
#[derive(Subcommand)]
enum Commands {
/// Compile an MDS file to Markdown or JSON messages (output shape is intrinsic)
///
/// Templates with `@message` blocks compile to a JSON array (.json).
/// All other templates compile to Markdown (.md).
/// The output extension is derived automatically from the compiled kind.
#[command(
after_help = "Examples:\n mds build Auto-detect the .mds file in current dir\n mds build template.mds Compile to template.md (next to source)\n mds build chat.mds Compile @message template to chat.json\n mds build template.mds -o - Compile to stdout\n mds build template.mds -o output.md Compile to specific file\n mds build template.mds --out-dir dist Compile to dist/template.md or dist/template.json\n mds build template.mds --vars vars.json With variable overrides\n mds build template.mds --set name=Alice Set a single variable\n echo \"Hello {{name}}!\" | mds build - Compile from stdin (writes to stdout)"
)]
Build {
/// Input .mds file (use "-" for stdin; omit to auto-detect in current directory)
input: Option<PathBuf>,
/// Output destination: a file path, or "-" for stdout.
/// Defaults to `<name>.md` or `<name>.json` next to the source file, based on output kind.
/// Mutually exclusive with --out-dir.
// Taken as given, like `--out-dir`: a value that is not valid UTF-8 is refused
// as `mds::io` by `build::reject_forbidden_output_flags`, not by the parser (#390).
#[arg(short = 'o', long = "output", conflicts_with = "out_dir")]
output: Option<OsString>,
/// Output directory. The output file is named `<input-stem>.md` or `<input-stem>.json`
/// inside this directory, based on output kind.
/// Directory is created if it does not exist.
/// Mutually exclusive with -o/--output.
#[arg(long = "out-dir", conflicts_with = "output")]
out_dir: Option<PathBuf>,
/// JSON file with runtime variable overrides (a repeated key warns; the last value wins)
#[arg(long)]
vars: Option<PathBuf>,
/// Set a runtime variable (repeatable, e.g. --set name=Alice --set count=3; repeating a key warns, last value wins)
#[arg(long = "set", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_vars: Vec<(String, String)>,
/// Set a runtime variable as a string (repeatable, no type coercion; e.g. --set-string count=3 sets count to the string "3"; repeating a key warns, last value wins)
#[arg(long = "set-string", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_string_vars: Vec<(String, String)>,
/// Generate a source map alongside the compiled output (sidecar: `<output-file>`.map, e.g. -o out.md → out.md.map).
/// Conflicts with --no-source-map.
#[arg(long = "source-map", conflicts_with = "no_source_map")]
source_map: bool,
/// Disable source-map generation (overrides mds.json build.source_map=true).
/// Conflicts with --source-map.
#[arg(long = "no-source-map", conflicts_with = "source_map")]
no_source_map: bool,
/// Embed the source map as a data URI comment in the output file instead of a sidecar.
/// Requires --source-map.
#[arg(long = "inline", requires = "source_map")]
inline: bool,
/// Embed source file contents in sourcesContent[]. Ships full source text — use with care.
/// Requires --source-map.
#[arg(long = "embed-sources", requires = "source_map")]
embed_sources: bool,
},
/// Validate an MDS file without rendering
#[command(
after_help = "Examples:\n mds check Auto-detect the .mds file in current dir\n mds check template.mds Validate a specific file\n mds check template.mds --set name=Alice Validate with variable overrides"
)]
Check {
/// Input .mds file (use "-" for stdin; omit to auto-detect in current directory)
input: Option<PathBuf>,
/// JSON file with runtime variable overrides (a repeated key warns; the last value wins)
#[arg(long)]
vars: Option<PathBuf>,
/// Set a runtime variable (repeatable, e.g. --set name=Alice --set count=3; repeating a key warns, last value wins)
#[arg(long = "set", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_vars: Vec<(String, String)>,
/// Set a runtime variable as a string (repeatable, no type coercion; e.g. --set-string count=3 sets count to the string "3"; repeating a key warns, last value wins)
#[arg(long = "set-string", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_string_vars: Vec<(String, String)>,
},
/// Reformat MDS file(s) in place (opinionated, safety-gated)
///
/// Rewrites are guaranteed compile-equivalent: a safety gate re-compiles the
/// formatted source and refuses to write if it would change compiled output.
/// Normalizes line endings to LF on directive lines, strips trailing
/// whitespace on directive lines, and ensures exactly one final newline —
/// never touches body-text content (Markdown hard breaks, blank-line
/// structure, whitespace-only lines), frontmatter / code-fence internals,
/// or the byte-for-byte content of `@message` / `@define` bodies.
#[command(
after_help = "Examples:\n mds fmt Auto-detect and format the .mds file in current dir\n mds fmt template.mds Format a file in place\n mds fmt . Format every .mds file recursively (incl. partials)\n mds fmt --check template.mds Exit 1 if the file would change; writes nothing\n mds fmt --diff template.mds Print a unified diff of pending changes; writes nothing\n mds fmt --check --diff . Show diffs for every file that would change, exit 1 if any would\n printf '@if ready: \\nGo\\n@end\\n' | mds fmt - Format from stdin, write to stdout; creates no file"
)]
Fmt {
/// Input .mds file, directory, or "-" for stdin (omit to auto-detect in current directory)
input: Option<PathBuf>,
/// Read-only: exit non-zero if any file would change; never writes
#[arg(long)]
check: bool,
/// Read-only: print a unified diff of pending changes; never writes.
/// Combines with --check (diff is the rendering, check is the exit behavior).
#[arg(long)]
diff: bool,
},
/// Check MDS files for style and correctness issues beyond `mds check`
///
/// Runs 10 static-analysis rules (3 error-level, 6 warning-level, 1 default-off) on the file
/// without executing it. Partials and imported files are included in directory mode.
///
/// Exit codes: 0 = clean, 1 = warnings only, 2 = errors, analysis failure or I/O
/// failure, 3 = resource limit, 101 = internal compiler error (a panic).
///
/// Directory mode prints one summary line to stderr after processing all files:
/// N clean, N with warnings, N with errors, N resource-limited
///
/// Under --quiet the summary is suppressed on a warn-only or clean run, but is
/// always printed when error- or resource-limited files are present. --quiet also
/// suppresses the `fix rejected:` and `diagnostic cap reached` notices in every
/// input mode. Two cases produce exit 1 with zero stderr bytes under --quiet:
/// (a) --fix --check: pending fixes exist but no error-severity findings are
/// present — the pending-fix signal is status output and is suppressed by --quiet;
/// (b) directory mode, warn-only run: files have warnings but no errors — the
/// summary is suppressed, mirroring `mds fmt --check --quiet` which also exits 1
/// silently when only formatting changes are present.
#[command(
after_help = "Examples:\n mds lint template.mds Lint a single file\n mds lint . Lint all .mds files recursively\n mds lint --fix template.mds Fix auto-fixable issues in place\n mds lint --fix --check template.mds Preview fixes (exit 1 if any would apply)\n mds lint --fix --diff template.mds Show diff of pending fixes\n mds lint --format json template.mds Machine-readable JSON output\n mds lint --quiet . Directory lint: silent on clean/warn-only; summary prints on errors or resource limits\n mds lint --quiet template.mds Suppress output; exits 1 on warnings, 2 on errors\n cat template.mds | mds lint - Lint from stdin\n cat template.mds | mds lint --fix - Fix from stdin, write fixed source to stdout"
)]
Lint {
/// Input .mds file, directory, or `-` for stdin (omit to auto-detect)
input: Option<PathBuf>,
/// Apply auto-fixable issues in place (Tier A always; Tier B when standalone)
#[arg(long)]
fix: bool,
/// With --fix: exit 1 if any file would change; never writes
#[arg(long, requires = "fix")]
check: bool,
/// With --fix: print unified diff of pending changes; never writes
#[arg(long, requires = "fix")]
diff: bool,
/// Output format: `human` (default, stderr) or `json` (stdout)
#[arg(long = "format", value_name = "FORMAT", default_value = "human")]
format: String,
/// JSON file with runtime variable overrides (a repeated key warns; the last value wins)
#[arg(long)]
vars: Option<PathBuf>,
/// Set a runtime variable (repeatable, e.g. --set name=Alice; repeating a key warns, last value wins)
#[arg(long = "set", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_vars: Vec<(String, String)>,
/// Set a runtime variable as a string (repeatable, no type coercion; repeating a key warns, last value wins)
#[arg(long = "set-string", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_string_vars: Vec<(String, String)>,
},
/// Create a starter MDS file
Init {
/// Output filename
#[arg(default_value = "hello.mds")]
filename: PathBuf,
/// Overwrite existing file
#[arg(long)]
force: bool,
},
/// Watch an MDS file (or directory) and recompile on changes
///
/// Single-file mode tracks transitive imports — editing any imported file
/// triggers a recompile of the entry. Directory mode tracks a reverse-dependency
/// graph: editing a shared partial recompiles all transitive importers.
/// `_`-prefixed files are partials (tracked, not emitted to their own output).
/// Cross-root imports are watched NonRecursively.
///
/// Output mirrors the source subtree under `--out-dir` / `mds.json output_dir`.
/// The output extension is determined by the compiled kind (.md or .json).
///
/// A liveness-gated reconcile fallback re-arms watches each tick and does a full
/// rescan only on watch loss/recovery. Use `--poll-interval 0` to disable.
#[command(
after_help = "Examples:\n mds watch template.mds Watch a single file, write template.md\n mds watch chat.mds Watch @message template, write chat.json\n mds watch template.mds -o out.md Watch to a specific output file\n mds watch template.mds -o - Watch, stream output to stdout\n mds watch . Watch all .mds files in current directory\n mds watch src/ --out-dir dist Watch directory, mirror to dist/ subtree\n mds watch template.mds --vars v.json Watch with variable overrides\n mds watch template.mds --clear Clear terminal before each rebuild\n mds watch src/ --poll-interval 500 Self-heal check every 500ms\n mds watch src/ --poll-interval 0 Disable self-heal (native events only)"
)]
Watch {
/// File or directory to watch. Omit to auto-detect a single .mds file.
/// Use "-" to read from stdin (not supported — use build instead).
input: Option<PathBuf>,
/// Output destination: a file path, or "-" for stdout.
/// Mutually exclusive with --out-dir. Not allowed in directory mode.
// Taken as given, like `--out-dir`: a value that is not valid UTF-8 is refused
// as `mds::io` by `build::reject_forbidden_output_flags`, not by the parser (#390).
#[arg(short = 'o', long = "output", conflicts_with = "out_dir")]
output: Option<OsString>,
/// Output directory for compiled files (directory mode).
/// Output mirrors the source subtree: src/a/b/foo.mds → out/a/b/foo.md.
/// Mutually exclusive with -o/--output.
#[arg(long = "out-dir", conflicts_with = "output")]
out_dir: Option<PathBuf>,
/// JSON file with runtime variable overrides (reloaded on each rebuild; a repeated key warns on each rebuild that writes output, last value wins)
#[arg(long)]
vars: Option<PathBuf>,
/// Set a runtime variable (repeatable, e.g. --set name=Alice --set count=3; repeating a key warns, last value wins)
#[arg(long = "set", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_vars: Vec<(String, String)>,
/// Set a runtime variable as a string (repeatable, no type coercion; e.g. --set-string count=3 sets count to the string "3"; repeating a key warns, last value wins)
#[arg(long = "set-string", value_name = "KEY=VALUE", value_parser = parse_key_value)]
set_string_vars: Vec<(String, String)>,
/// Clear the terminal before the first line each rebuild prints (only when stderr is a TTY)
#[arg(long)]
clear: bool,
/// Quiet period in milliseconds before a rebuild (default 100).
/// Each file change restarts the window, so a save burst longer than MS still
/// coalesces into one rebuild; the window is capped at max(10 x MS, 1000) ms so
/// continuous writes still rebuild. Use 0 to disable coalescing.
/// Values above 60000 are clamped. At any value, a rebuild waits while a watched
/// file is empty after having had content, as during a truncate-then-write save,
/// until it is written or for about 1000 ms, after which the empty file is
/// compiled; longer only while a debounce window opened before then is still
/// collecting events, by at most that window's cap.
#[arg(long = "debounce", value_name = "MS", default_value = "100")]
debounce: u64,
/// Self-heal poll interval in milliseconds (default 1000).
/// Each tick re-arms watches and runs a liveness check; a full rescan only
/// runs on watch loss/recovery. Use 0 to disable (native events only).
/// Non-zero values are clamped to a 50ms minimum.
#[arg(long = "poll-interval", value_name = "MS", default_value = "1000")]
poll_interval: u64,
},
}
fn main() {
// #389: first, so that any panic after it — clap's parsing included — prints the
// fixed internal-compiler-error text, never the panic's message.
output::install_panic_hook();
let cli = match Cli::try_parse() {
Ok(cli) => cli,
Err(err) => exit_after_clap_output(&err),
};
// A panic in the command unwinds to here, running the destructors on its way (a
// temporary file removes itself), and the run exits 101 through the funnel. The hook
// has reported it.
let verdict = match output::catch_panic(move || verdict_of(run(cli))) {
Ok(verdict) => verdict,
Err(output::Panicked) => output::PANIC_EXIT,
};
output::exit(verdict)
}
/// The exit code of a command's result, its error reported first when it has one.
fn verdict_of(result: Result<()>) -> i32 {
match result {
Ok(()) => 0,
Err(e) => {
// Route through the single render choke point, never a hand-rolled
// sanitize_control_chars. Every subcommand's error propagates here; guarding
// here makes the protection hold by construction for any future error path,
// not just the ones we remember to sanitize individually.
let code = exit_code(&e);
output::eprint_error(e);
code
}
}
}
/// Print clap's help, version or usage error and end the run with clap's exit code — 0
/// for help and version, 2 for a usage error — under the rule every other output
/// follows (#157): a closed pipe changes nothing; any other failed write exits at least
/// 2, a failed stdout write reported on stderr as `mds::io`.
fn exit_after_clap_output(err: &clap::Error) -> ! {
let printed = err
.print()
.and_then(|()| std::io::Write::flush(&mut std::io::stdout()));
if let Err(e) = printed {
if e.kind() != std::io::ErrorKind::BrokenPipe {
if err.use_stderr() {
// stderr itself failed, so there is nowhere to report it.
output::note_io_failure();
} else {
output::eprint_io_failure(output::stdout_failure(&e));
}
}
}
output::exit(err.exit_code())
}
fn run_check(
input: Option<PathBuf>,
vars: Option<PathBuf>,
set_vars: Vec<(String, String)>,
set_string_vars: Vec<(String, String)>,
quiet: bool,
) -> Result<()> {
use build::read_stdin;
use output::STDIN_DISPLAY_LABEL;
let resolved = build_runtime_vars(RuntimeVarArgs {
vars,
set_vars,
set_string_vars,
})?;
emit_duplicate_var_warnings(&resolved, quiet);
let runtime_vars = resolved.vars;
// Resolve the input: explicit path/stdin, or auto-detect from cwd.
// run_check does not print a banner on auto-detect — check is a silent validation.
let (input, _) = resolve_input(input, "check")?;
// Directory mode: validate every non-partial .mds file in the tree.
if input != std::path::Path::new("-") && input.is_dir() {
// #413: the one directory-argument check every directory-mode subcommand makes
// (a symlink, the filesystem root, a forbidden character — all `mds::io`).
let canonical_dir =
input::resolve_directory_argument(&input).map_err(miette::Error::from)?;
return run_check_directory(&input, &canonical_dir, runtime_vars, quiet);
}
// Single-file / stdin path.
if input == std::path::Path::new("-") {
let source = read_stdin()?;
// AD-211-1 / AD-211-5: a string-source check labels its errors `<source>`
// (resolver's SOURCE_LABEL). Relabel to the uniform CLI sentinel here, at the
// boundary that knows the input was stdin. `None` is the working directory,
// shown as "." (see `read_stdin`).
let ((), warnings) = mds::check_str_collecting_warnings(&source, None, runtime_vars)
.map_err(|e| output::relabel_stdin_error(&e, &source))?;
if !quiet {
for w in &warnings {
output::eprint_warning(w);
}
// AD-211-3: one definition of the sentinel, shared with lint/build/fmt.
output::ewriteln!("OK: {STDIN_DISPLAY_LABEL}");
}
} else {
let ((), warnings) =
mds::check_collecting_warnings(&input, runtime_vars).map_err(miette::Error::from)?;
if !quiet {
for w in &warnings {
output::eprint_warning(w);
}
output::ewriteln!("OK: {}", output::safe_path(&input));
}
}
Ok(())
}
/// Validate every non-partial `.mds` file under `dir`.
///
/// Continue-on-error: a per-file error does not abort the run. Prints a summary and
/// returns non-zero if any file fails: 1 for a template error, 2 when an I/O or
/// file-system failure is among them, as for `mds build <dir>` (#157), and 3 when a file
/// failed with a resource limit.
fn run_check_directory(
dir: &std::path::Path,
canonical_dir: &std::path::Path,
runtime_vars: Option<std::collections::HashMap<String, mds::Value>>,
quiet: bool,
) -> Result<()> {
use output::{collect_mds_files_detailed, is_partial};
const MAX_DEPTH: usize = 64;
let walk = collect_mds_files_detailed(dir, MAX_DEPTH, None);
let files = &walk.files;
if files.is_empty() {
if walk.excluded_by_default > 0 {
// Always emit — not suppressed by --quiet (avoids silent CI green pass).
output::ewriteln!(
"{} .mds file(s) found but all are under default-excluded directories \
(hidden dirs, node_modules); nothing was checked",
walk.excluded_by_default
);
output::exit(1);
}
// #204: an empty tree is "nothing to check", not success (mirrors build.rs).
// Emitted even under --quiet and exit 1, the same "nothing was done" code
// build and fmt use.
output::ewriteln!(
"no .mds files found in {}; nothing was checked",
output::safe_path(dir)
);
output::exit(1);
}
// #387: a tree whose only .mds files are partials is "nothing to check" too. The
// walker collects partials (watch/fmt/lint need them) but this loop skips them, so
// without this arm the run ends `0 passed, 0 failed`, exit 0 — the silent green pass
// #204 closed for the empty tree. Same shape as the all-excluded arm: count-carrying,
// emitted even under --quiet, exit 1. fmt and lint operate on partials and keep their
// behaviour; `mds watch <dir>` still starts.
if let Some(partials_only_count) = output::partials_only(files) {
output::ewriteln!(
"{partials_only_count} .mds file(s) found in {} but all are _-prefixed partials; \
nothing was checked",
output::safe_path(dir)
);
output::exit(1);
}
let mut ok_count: usize = 0;
let mut fail_count: usize = 0;
for file in files {
if is_partial(file) {
continue;
}
// A panic in the check fails this file alone, and the batch goes on (#389).
let pin = match output::walked_pin(&walk, file, dir, canonical_dir) {
Ok(pin) => pin,
Err(e) => {
output::eprint_file_failure(e.into());
fail_count += 1;
continue;
}
};
let fs = mds::NativeFs::new().with_entry_pin(pin);
let checked = output::catch_compile(
file,
AssertUnwindSafe(|| mds::check_native_fs(fs, file, runtime_vars.clone())),
);
match checked {
Ok(Ok(warnings)) => {
if !quiet {
for w in &warnings {
output::eprint_warning(w);
}
}
ok_count += 1;
}
Ok(Err(e)) => {
// Route through the single render choke point, so no path renders a
// report without its escaping; a source that cannot be read lifts the
// exit code to 2, one over a resource limit to 3 (#157).
output::eprint_file_failure(miette::Error::from(e));
fail_count += 1;
}
// The panic hook reported it, and the run will exit 101.
Err(output::Panicked) => fail_count += 1,
}
}
if !quiet || fail_count > 0 {
output::ewriteln!("{ok_count} passed, {fail_count} failed");
}
if fail_count > 0 {
output::exit(1);
}
Ok(())
}
fn run_init(filename: PathBuf, force: bool, quiet: bool) -> Result<()> {
// #265: refuse a hostile filename before anything is read or written — the
// same up-front check `-o`/`--out-dir`/`build.output_dir` apply
// (`reject_forbidden_output_flags`, build.rs).
output::reject_forbidden_output_path("init filename", filename.as_os_str())?;
if filename
.components()
.any(|c| c == std::path::Component::ParentDir)
{
return Err(miette::miette!(
"init filename must not contain '..' components"
));
}
// An early answer only: a file that appears after this look is refused by the commit
// itself (`write::create_new`, #160), in the same way.
if filename.exists() && !force {
return Err(init_target_exists(&filename));
}
let starter = "\
---
name: World
items: [one, two, three]
---
<!-- Frontmatter above is emitted to output verbatim; runtime --set/--vars change only the body below -->
Hello {{name}}!
Your items:
@for item in items:
- {{item}}
@end
";
// #386: the same primitive as every other CLI write — a symlink at `filename` (live
// under `--force`, dangling without it) is refused instead of written through;
// `--force` replaces a regular file by rename with its permission bits kept, and
// without it the starter is committed only where nothing is, so a file that appeared
// after the check above is refused, not replaced (#160). `RenameOnly` because the starter is a
// fixed public template a re-run reproduces. Anchored at the typed parent, which must
// exist: init creates no directory (#160).
let target = output::WriteTarget::as_typed(filename.clone());
let (durability, parents) = (write::Durability::RenameOnly, write::Parents::Existing);
if force {
write::atomic_write_file(&target, starter, durability, parents)?;
} else {
write::create_new(&target, starter, durability, parents).map_err(|not_created| {
match not_created {
write::NotCreated::Exists => init_target_exists(&filename),
write::NotCreated::Failed(e) => miette::Report::new(e),
}
})?;
}
if !quiet {
output::ewriteln!(
"Created {}\n Try: mds build {}",
output::safe_path(&filename),
output::safe_path(&filename)
);
}
Ok(())
}
/// `mds init`'s refusal of a file at its target (#160): `<file> already exists (use
/// --force to overwrite)`, exit 1, no error code — one answer whether its look found the
/// file there or the commit met one that appeared after that look.
fn init_target_exists(filename: &std::path::Path) -> miette::Report {
miette::miette!("{} {}", output::safe_path(filename), write::ALREADY_EXISTS)
}
fn run(cli: Cli) -> Result<()> {
output::panic_on_request();
let quiet = cli.quiet;
match cli.command {
Commands::Build {
input,
output,
out_dir,
vars,
set_vars,
set_string_vars,
source_map,
no_source_map,
inline,
embed_sources,
} => run_build(BuildArgs {
input,
output,
out_dir,
vars,
set_vars,
set_string_vars,
quiet,
source_map,
no_source_map,
inline,
embed_sources,
}),
Commands::Check {
input,
vars,
set_vars,
set_string_vars,
} => run_check(input, vars, set_vars, set_string_vars, quiet),
Commands::Fmt { input, check, diff } => fmt::run_fmt(fmt::FmtArgs {
input,
check,
diff,
quiet,
}),
Commands::Lint {
input,
fix,
check,
diff,
format,
vars,
set_vars,
set_string_vars,
} => {
let fmt = match format.as_str() {
"human" => lint::LintFormat::Human,
"json" => lint::LintFormat::Json,
other => {
output::ewriteln!(
"error: unknown --format value '{}'; expected 'human' or 'json'",
output::safe_inline(other)
);
output::exit(2);
}
};
output::exit(lint::run_lint(lint::LintArgs {
input,
fix,
check,
diff,
quiet,
format: fmt,
vars,
set_vars,
set_string_vars,
}))
}
Commands::Init { filename, force } => run_init(filename, force, quiet),
Commands::Watch {
input,
output,
out_dir,
vars,
set_vars,
set_string_vars,
clear,
debounce,
poll_interval,
} => watch::run_watch(watch::WatchArgs {
input,
output,
out_dir,
vars,
set_vars,
set_string_vars,
clear,
debounce,
quiet,
poll_interval,
}),
}
}
// This file only contains integration-level wiring that is covered by the integration tests.