//! tidalDB CLI embedding: open a persistent database and print status. //! //! Demonstrates: //! - Opening a persistent `TidalDb` with an explicit data directory //! - Printing build hash, uptime, and debug info //! - Explicit `close()` before exit //! //! In a real CLI this data directory would come from a flag or config file. //! Here we use a temporary directory so the example runs safely in CI. //! //! # Running //! //! ```bash //! cargo run --example cli_embedding --manifest-path tidal/Cargo.toml //! ``` fn main() -> Result<(), Box> { tracing_subscriber::fmt() .with_env_filter("tidaldb=debug") .init(); // Create a temporary directory to act as the data root. // In a production CLI, replace this with the user-supplied path. let tmp = tempfile::tempdir()?; let data_dir = tmp.path(); let db = tidaldb::TidalDb::builder().with_data_dir(data_dir).open()?; println!("build: {}", tidaldb::BUILD_HASH); println!("data: {}", data_dir.display()); println!("uptime: {:.3}s", db.metrics().uptime_seconds()); println!("health: {:?}", db.health_check()); println!("debug: {db:?}"); // Explicit close — ensures any future WAL flush completes before exit. db.close()?; println!("shutdown complete."); Ok(()) }