Skip to main content

Crate config_easy

Crate config_easy 

Source
Expand description

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

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()?;

Structs§

ConfigMenu
A configurable terminal menu for viewing and editing application settings.

Enums§

ConfigEasyError
A custom error type for the configuration menu, encompassing various error scenarios that may occur during menu operation.

Functions§

builder
Creates a configurable settings menu for the provided SQLite connection.
run
Runs a settings menu with the default configuration.