config-easy
config-easy is a small Rust crate for displaying and editing key/value settings stored in a SQLite table.
It is intended for command-line applications that want a simple interactive configuration menu, usually shown when the application is run with a --config option.
Applications remain responsible for schema creation, default values, typed configuration structs, CLI parsing, and app-specific behavior.
Install
[]
= "0.1"
= "0.32"
Default Schema
(
key TEXT PRIMARY KEY,
value TEXT NOT NULL
);
Basic Usage
let connection = open?;
run?;
This uses:
- table:
settings - key column:
key - value column:
value - order by:
key
Builder Usage
builder
.table
.key_column
.value_column
.order_by
.run?;
Table and column names are validated as simple SQL identifiers before being interpolated into SQL. Values are always bound as SQL parameters.
Valid identifiers are non-empty, start with an ASCII letter or _, and contain only ASCII letters, numbers, and _.
Secret Values
builder
.secret_keys
.run?;
Non-empty secret values are displayed as ********. Empty secret values are displayed as empty. The underlying value is not changed unless the user selects that setting and enters a new value.
Validation
builder
.validator
.run?;
Validation runs before a setting is updated.
Input values are trimmed before validation and saving.
Custom Actions
builder
.action
.run?;
Custom actions are displayed in the prompt and run when their key is selected. Action keys cannot be empty, numeric, duplicated, q, or quit.
Deliberately Not Included
- Creating the settings table
- Seeding default settings
- Parsing values into app-specific types
- CLI argument parsing
- Encryption or secure secret storage
- App-specific maintenance logic