salak-0.3.0 has been yanked.
salak
A configuration loader with zero-boilerplate configuration management.
About
salak try to provide an out-of-box configuration loader for creating new apps, such as cli, web, servers.
Multi-Layered source environment.
salak defines following default PropertySources:
- Command line arguments using
clapto parsing-P, --propery KEY=VALUE. - System Environment.
- app.toml(*) in current dir and $HOME dir. Or if you specify
APP_CONF_DIRdir, then only load toml in this dir.
* APP_CONF_NAME can be specified to replace app.
Placeholder format
salak use format {key:default} to reference to other key, and if key not exists then use value default.
Key format
a.b.cis a normal key separated by dot(.).a.b.0,a.b.1,a.b.2... is a group of keys with arrays.- System environment key will be changed from
HELLO_WORLDtohello.world, vice versa.
Auto derived parameters.
attribute default to set default value.
#[salak(default="string")]#[salak(default=1)]
attribute disable_placeholder to disable placeholder parsing.
#[salak(disable_placeholder)]#[salak(disable_placeholder = true)]
Quick Code
use *;
// Output: DatabaseConfig { url: "localhost:5432", name: "salak", username: "salak", password: None, description: "{Hello}" }
Quick Run
# salak 0.2.0
# Daniel Yu <leptonyu@gmail.com>
# A rust configuration loader
#
# USAGE:
# salak [OPTIONS]
#
# FLAGS:
# -h, --help Prints help information
# -V, --version Prints version information
#
# OPTIONS:
# -P, --property <KEY=VALUE>... Set properties
TODO
- Support hashmap.
- Support toml date.
- Reload configurations.