1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! 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>>(())
//! ```
pub use ConfigEasyError;
pub use 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`].
/// Runs a settings menu with the default configuration.
///
/// This is equivalent to `config_easy::builder(conn).run()`.