Skip to content
/ figment2 Public

Fork of figment: A hierarchical configuration library

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

lmmx/figment2

Repository files navigation

figment2   ci.svg crates.io docs.rs

Remaintained fork of figment

Figment2 is a semi-hierarchical configuration library for Rust so con-free, it's unreal.

use serde::Deserialize;

use figment2::{Figment, providers::{Format, Toml, Json, Env}};

#[derive(Deserialize)]
struct Package {
    name: String,
    authors: Vec<String>,
    publish: Option<bool>,
    // ... and so on ...
}

#[derive(Deserialize)]
struct Config {
    package: Package,
    rustc: Option<String>,
    // ... and so on ...
}

let config: Config = Figment::new()
    .merge(Toml::file("Cargo.toml"))
    .merge(Env::prefixed("CARGO_"))
    .merge(Env::raw().only(&["RUSTC", "RUSTDOC"]))
    .join(Json::file("Cargo.json"))
    .extract()?;

See the documentation for a detailed usage guide and information.

Usage

Add the following to your Cargo.toml, enabling the desired built-in providers:

[dependencies]
figment2 = { version = "0.11", features = ["toml"] }

License

Figment is licensed under either of the following, at your option:

About

Fork of figment: A hierarchical configuration library

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 16