ANW-10 bootstrap anwesen crate and CLI skeleton

This commit is contained in:
Andreas Brenner 2026-05-14 14:24:38 +02:00
parent 0c21e6c5ff
commit 317667cce7
9 changed files with 3099 additions and 0 deletions

49
src/main.rs Normal file
View file

@ -0,0 +1,49 @@
//! 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;
use anyhow::Result;
use clap::Parser;
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,
"anwesen serve: not yet implemented (ANW-10 stub)"
);
}
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) {
let filter = tracing_subscriber::EnvFilter::try_from_env("ANWESEN_LOG")
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(level.as_filter_directive()));
let _ = tracing_subscriber::fmt()
.with_env_filter(filter)
.with_writer(std::io::stderr)
.try_init();
}