config-easy 0.1.0

A small SQLite-backed interactive settings menu for command-line Rust applications
Documentation
//! A small SQLite-backed interactive settings menu for command-line applications.
//!
//! `config-easy` reads key/value settings from a SQLite table, displays them in
//! a terminal menu, prompts for edits, optionally validates new values, and saves
//! updates back to SQLite.
//!
//! Applications remain responsible for creating tables, seeding defaults,
//! parsing typed configuration, and deciding when to show the menu.
//!
//! # Example
//!
//! ```no_run
//! let connection = rusqlite::Connection::open("app.db")?;
//!
//! config_easy::builder(&connection)
//!     .secret_keys(["api_token"])
//!     .validator(|key, value| {
//!         if key == "log_level" && !["debug", "info", "warn", "error"].contains(&value) {
//!             return Err(std::io::Error::new(
//!                 std::io::ErrorKind::InvalidInput,
//!                 "expected one of debug, info, warn, error",
//!             )
//!             .into());
//!         }
//!
//!         Ok(())
//!     })
//!     .run()?;
//!
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```

mod action;
mod error;
mod identifier;
mod menu;
mod row;

pub use error::ConfigEasyError;
pub use menu::ConfigMenu;

/// Creates a configurable settings menu for the provided SQLite connection.
///
/// By default, the menu reads from `settings(key, value)` and orders rows by
/// `key`. Use the returned [`ConfigMenu`] to customize table names, secret keys,
/// validation, ordering, or custom actions before calling [`ConfigMenu::run`].
pub fn builder(conn: &rusqlite::Connection) -> ConfigMenu<'_> {
    ConfigMenu::new(conn)
}

/// Runs a settings menu with the default configuration.
///
/// This is equivalent to `config_easy::builder(conn).run()`.
pub fn run(conn: &rusqlite::Connection) -> Result<(), ConfigEasyError> {
    builder(conn).run()
}