summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2017-02-12 11:04:38 -0800
committerRyan Leckey <leckey.ryan@gmail.com>2017-02-12 11:04:38 -0800
commit27466dc948c1902c8fe292a0c7bc1d0bc40570c5 (patch)
tree294c3d533912e5946db157e0d93327b5865279b4
parente29748b255ce97dfe9b4efcfbc4d9bcb3d694b97 (diff)
parent63dbca6b071b1e4e872af96325b2865bb950b147 (diff)
Merge branch 'master' of https://github.com/mehcode/config-rs
-rw-r--r--README.md50
1 files changed, 3 insertions, 47 deletions
diff --git a/README.md b/README.md
index 2896789..705a46d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
# config-rs
+![Rust](https://img.shields.io/badge/rust-stable-brightgreen.svg)
[![Build Status](https://travis-ci.org/mehcode/config-rs.svg?branch=master)](https://travis-ci.org/mehcode/config-rs)
[![Crates.io](https://img.shields.io/crates/d/config.svg)](https://crates.io/crates/config)
[![Docs.rs](https://docs.rs/config/badge.svg)](https://docs.rs/config)
@@ -17,7 +18,7 @@
[TOML]: https://github.com/toml-lang/toml
[YAML]: https://github.com/chyh1990/yaml-rust
-## Install
+## Usage
```toml
[dependencies]
@@ -28,52 +29,7 @@ config = "0.2"
- `yaml` - Adds support for reading YAML files
- `toml` - Adds support for reading TOML files (included by default)
-## Usage
-
-Configuration is gathered by building a `Source` and then merging that source into the
-current state of the configuration.
-
-```rust
-fn main() {
- // Add environment variables that begin with RUST_
- config::merge(config::Environment::new("RUST"));
-
- // Add 'Settings.json'
- config::merge(config::File::new("Settings", config::FileFormat::Json));
-
- // Add 'Settings.$(RUST_ENV).json`
- let name = format!("Settings.{}", config::get_str("env").unwrap());
- config::merge(config::File::new(&name, config::FileFormat::Json));
-}
-```
-
-Note that in the above example the calls to `config::merge` could have
-been re-ordered to influence the priority as each successive merge
-is evaluated on top of the previous.
-
-Configuration values can be retrieved with a call to `config::get` and then
-coerced into a type with `as_*`.
-
-```toml
-# Settings.toml
-debug = 1
-```
-
-```rust
-fn main() {
- // Add 'Settings.toml' (from above)
- config::merge(config::File::new("Settings", config::FileFormat::Toml));
-
- // Get 'debug' and coerce to a boolean
- assert_eq!(config::get("debug").unwrap().as_bool(), Some(true));
-
- // You can use a type suffix on `config::get` to simplify
- assert_eq!(config::get_bool("debug"), Some(true));
- assert_eq!(config::get_str("debug"), Some("true"));
-}
-```
-
-See the [examples](https://github.com/mehcode/config-rs/tree/master/examples) for
+See the [documentation](https://docs.rs/config) or [examples](https://github.com/mehcode/config-rs/tree/master/examples) for
more usage information.
## License