2026-05-14 14:24:38 +02:00
|
|
|
//! 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].
|
|
|
|
|
|
|
|
|
|
mod cli;
|
|
|
|
|
|
2026-05-14 14:49:02 +02:00
|
|
|
use anwesen::app::Anwesen;
|
2026-05-14 14:24:38 +02:00
|
|
|
use anyhow::Result;
|
|
|
|
|
use clap::Parser;
|
2026-05-14 14:49:02 +02:00
|
|
|
use hydra::Application;
|
2026-05-14 14:24:38 +02:00
|
|
|
|
|
|
|
|
use crate::cli::{Cli, Command};
|
|
|
|
|
|
|
|
|
|
// Result is retained at the binary boundary per [[ADR-001 Language and
|
|
|
|
|
// Foundation Libraries]] (anyhow at main); current stubs do not yet
|
|
|
|
|
// surface errors.
|
|
|
|
|
#[allow(clippy::unnecessary_wraps)]
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
|
let cli = Cli::parse();
|
|
|
|
|
match cli.command {
|
|
|
|
|
Command::Serve(args) => {
|
|
|
|
|
init_logging(args.log_level);
|
|
|
|
|
tracing::info!(
|
|
|
|
|
vault = %args.vault.display(),
|
|
|
|
|
bind = %args.bind,
|
2026-05-14 14:49:02 +02:00
|
|
|
"anwesen serve: starting supervisor tree"
|
2026-05-14 14:24:38 +02:00
|
|
|
);
|
2026-05-14 14:49:02 +02:00
|
|
|
// Blocks until the supervisor exits (SIGTERM / SIGINT / crash).
|
|
|
|
|
Anwesen::new(args.vault, args.bind).run();
|
2026-05-14 14:24:38 +02:00
|
|
|
}
|
|
|
|
|
Command::Doctor(args) => {
|
|
|
|
|
init_logging(args.log_level);
|
|
|
|
|
tracing::info!(
|
|
|
|
|
vault = %args.vault.display(),
|
|
|
|
|
"anwesen doctor: not yet implemented (ANW-10 stub)"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Command::Version => {
|
|
|
|
|
println!("{}", env!("CARGO_PKG_VERSION"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn init_logging(level: cli::LogLevel) {
|
2026-05-14 14:35:22 +02:00
|
|
|
// The User Manual lists --log-level / ANWESEN_LOG_LEVEL as the only knobs
|
|
|
|
|
// for verbosity, and pins "CLI flags win over environment variables".
|
|
|
|
|
// Resolution happens in clap; this function only builds the filter from
|
|
|
|
|
// the already-resolved level.
|
|
|
|
|
let filter = tracing_subscriber::EnvFilter::new(level.as_filter_directive());
|
2026-05-14 14:24:38 +02:00
|
|
|
let _ = tracing_subscriber::fmt()
|
|
|
|
|
.with_env_filter(filter)
|
|
|
|
|
.with_writer(std::io::stderr)
|
|
|
|
|
.try_init();
|
|
|
|
|
}
|