All Projects → leptonyu → cfg-rs

leptonyu / cfg-rs

Licence: MIT license
A Configuration Library for Rust Applications

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to cfg-rs

Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+816.67%)
Mutual labels:  config, yaml, toml, settings, configuration
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (+11.11%)
Mutual labels:  config, yaml, toml, settings, configuration
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (+1150%)
Mutual labels:  config, yaml, toml, configuration
Koanf
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.
Stars: ✭ 450 (+2400%)
Mutual labels:  config, yaml, toml, configuration
Config Lite
A super simple & flexible & useful config module.
Stars: ✭ 78 (+333.33%)
Mutual labels:  config, yaml, toml, configuration
Fig
A minimalist Go configuration library
Stars: ✭ 142 (+688.89%)
Mutual labels:  yaml, toml, environment, configuration
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+4116.67%)
Mutual labels:  config, yaml, toml, configuration
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+377.78%)
Mutual labels:  config, yaml, toml, configuration
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+11466.67%)
Mutual labels:  config, yaml, settings, configuration
Hoplite
A boilerplate-free library for loading configuration files as data classes in Kotlin
Stars: ✭ 322 (+1688.89%)
Mutual labels:  config, yaml, configuration
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (+4544.44%)
Mutual labels:  config, yaml, configuration
Mconfig
MCONFIG is a lightweight Golang library for integrating configs files like (json, yml, toml) and environment variables into one config struct.
Stars: ✭ 28 (+55.56%)
Mutual labels:  config, yaml, toml
Hiyapyco
HiYaPyCo - A Hierarchical Yaml Python Config
Stars: ✭ 58 (+222.22%)
Mutual labels:  config, yaml, configuration
Ins sandstorm
[INS] Config setting for our sandstorm server
Stars: ✭ 61 (+238.89%)
Mutual labels:  config, settings, configuration
Rime pure
【rime小狼毫\trime同文】手机/PC一站式配置【简约皮肤\拼音搜狗词库\原创trime同文四叶草九宫格拼音方案\四叶草拼音、小鹤双拼、极品五笔、徐码、郑码】 rime配置
Stars: ✭ 73 (+305.56%)
Mutual labels:  config, settings, configuration
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+4983.33%)
Mutual labels:  config, toml, configuration
Env
Simple lib to parse environment variables to structs
Stars: ✭ 2,164 (+11922.22%)
Mutual labels:  config, environment, configuration
environment
🌳 Environment variable configuration for Node.js made easy.
Stars: ✭ 12 (-33.33%)
Mutual labels:  config, environment, configuration
Environ Config
Python Application Configuration With Environment Variables
Stars: ✭ 210 (+1066.67%)
Mutual labels:  config, environment, configuration
go-config
Configuration file loader for Go
Stars: ✭ 27 (+50%)
Mutual labels:  yaml, toml, configuration

cfg-rs: A Configuration Library for Rust Applications

Crates.io Crates.io Documentation dependency status License Actions Status Minimum supported Rust version

Major Features

  • One method to get all config objects, see get.
  • Automatic derive config object, see FromConfig.
  • Support default value for config object by auto deriving, see derived attr.
  • Config value placeholder parsing, e.g. ${config.key}, see placeholder.
  • Random config value, e.g. configuration.get::<u8>("random.u8") will get random u8 value.
  • Support refreshable value type RefValue, it can be updated when refreshing.
  • Support refresh Configuration.
  • Easy to use, easy to add new config source, easy to organize configuration, see register_source.1

See the examples for general usage information.

Supported File Format

  • Toml: toml, tml
  • Yaml: yaml, yml
  • Json: json
  • Ini: ini

How to Initialize Configuration

  • Use Predefined Source Configuration in One Line
use cfg_rs::*;
let configuration = Configuration::with_predefined().unwrap();
// use configuration.

See init for details.

  • Customize Predefined Source Configuration Builder
use cfg_rs::*;
init_cargo_env!();
let configuration = Configuration::with_predefined_builder()
    .set_cargo_env(init_cargo_env())
    .init()
    .unwrap();
// use configuration.

See init for details.

  • Organize Your Own Sources
use cfg_rs::*;
init_cargo_env!();
let mut configuration = Configuration::new()
    // Layer 0: Register cargo env config source.
    .register_source(init_cargo_env()).unwrap()
    // Layer 1: Register customized config.
    .register_kv("customized_config")
        .set("hello", "world")
        .finish()
        .unwrap();
    // Layer 2: Register random value config.
#[cfg(feature = "rand")]
{
configuration = configuration.register_random().unwrap();
}
    // Layer 3: Register all env variables `CFG_*`.
configuration = configuration.register_prefix_env("CFG").unwrap()
    // Layer 4: Register yaml file(Need feature yaml).
    .register_file("/conf/app.yaml", true).unwrap();

#[cfg(feature = "toml")]
{
    let toml = inline_source!("../app.toml").unwrap();
    configuration = configuration.register_source(toml).unwrap();
}

// use configuration.

See register_kv, register_file, register_random, register_prefix_env for details.

Footnotes

  1. Config order is determined by the order of registering sources, register earlier have higher priority.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].