Confu
No frills app configuration via environment or command line arguments for software written in Rust.
Why Confu? Geared towards microservices, and has minimal direct dependencies
list: syn
, quote
, proc-macro2
, proc-macro-error
.
if a more user friendly command line parsing desired, there are great and proven crate alternatives. For example, Clap 👏.
Features
- at compile time (when a binary is produced for your app), captures
- build type, i.e.
debug
orrelease
- build version, if provided via environment variable
[PREFIX]VERSION
, otherwise is set to<unspecified>
- build type, i.e.
- Reads configuration from either
- environment
- command line arguments
- defaults
- configuration items may have an optional prefix like
APP_
- each config item can be
- required - if not provided, will
panic
- protected - will display "
xxxxxxx
" instead of sensitive information - hidden - will not be displayed at all
- required - if not provided, will
- Specificity: defaults -> environment -> arguments. Arguments being the most specific, will take precedence over the corresponding environment values, if such are also defined
Usage/Examples
A working example is provided in repository. And a quick usage summary here as well:
In Cargo.toml
:
[]
= "*"
then, a code like this:
use Confu;
should produce something like this, granted that APP_VERSION="0.1.0"
environment variable is also set:
APP_DB_USER/--app_db_user=postgres ()
APP_DB_PASSWORD/--app_db_password=xxxxxxx ()
APP_API_HOST/--app_api_host=127.0.0.1 ()
APP_TELEMETRY/--app_telemetry=yes ()
if a require argument was omitted, a panic
will occur:
Roadmap to v0.2.0
- Write the documentation
- Write the tests
- Produce a better error reporting in macros
- Parse into numerical and
bool
types