Skip to main content

obsidianlog_cli/
lib.rs

1//! ObsidianLog CLI library.
2//!
3//! Hosts the command-line surface (`init`, `serve`, `query`, `verify`), config
4//! loading, and the OS-keychain key store, wiring them to the
5//! [`obsidianlog_store`] and [`obsidianlog_ingest`] crates. The binary in
6//! `src/main.rs` is a thin shell over [`run`].
7//!
8//! # Status
9//!
10//! The argument surface is complete and dispatches to each command; `init`,
11//! `serve`, `query`, and `verify` are all implemented.
12
13pub mod backend;
14pub mod cli;
15pub mod commands;
16pub mod config;
17pub mod keystore;
18
19pub use cli::{Cli, Command};
20pub use config::Config;
21
22use anyhow::Result;
23
24/// Dispatch a parsed [`Cli`] invocation to the matching command handler.
25///
26/// This is the single entry point the binary calls into. The global `--config`
27/// path is threaded through to commands that read persisted state.
28pub fn run(cli: Cli) -> Result<()> {
29    match cli.command {
30        Command::Init(args) => commands::init::run(args, cli.config),
31        Command::Serve(args) => commands::serve::run(args, cli.config),
32        Command::Query(args) => commands::query::run(args, cli.config),
33        Command::Verify(args) => commands::verify::run(args, cli.config),
34    }
35}