ANW-27 CLI: anwesen merge -- one-shot local markdown-merge to stdout

Thin local front-end over ANW-26's merge engine (query::execute_merge):
walk the vault once (vault::scan, same as doctor), evaluate the --query
string, assemble the merged document, write it to stdout. No HTTP, no
watcher, no index. Byte-identical to the HTTP merge mode for the same
vault and query.
This commit is contained in:
Andreas Brenner 2026-06-14 21:18:06 +03:00
parent 03cc12e640
commit ed1759da59
4 changed files with 293 additions and 5 deletions

View file

@ -1,12 +1,13 @@
//! Anwesen: read-only HTTP daemon over a markdown vault.
//!
//! This module wires the CLI to the (still-stub) `serve` and `doctor`
//! subcommands. The full daemon arrives over [ANW-11..ANW-19].
//! This module wires the CLI to the `serve`, `doctor`, `merge`, and
//! `version` subcommands.
mod cli;
use anwesen::app::Anwesen;
use anwesen::doctor;
use anwesen::merge;
use anyhow::Result;
use clap::Parser;
use hydra::Application;
@ -38,6 +39,19 @@ fn main() -> Result<()> {
print!("{rendered}");
std::process::exit(exit);
}
Command::Merge(args) => {
init_logging(args.log_level);
match merge::run(&args.vault, &args.query) {
// `print!`, not `println!`: the merged document is byte-stable
// and byte-identical to the HTTP merge body, which carries no
// trailing newline. An empty match set prints nothing, exit 0.
Ok(doc) => print!("{doc}"),
Err(e) => {
eprint!("{}", e.render());
std::process::exit(1);
}
}
}
Command::Version => {
println!("{}", env!("CARGO_PKG_VERSION"));
}