doc: update readme
This commit is contained in:
parent
2d9b2bf0a1
commit
7bdf13f53e
3 changed files with 31 additions and 7 deletions
18
README.md
18
README.md
|
@ -20,6 +20,17 @@ config! {
|
||||||
DEBUG: bool => true,
|
DEBUG: bool => true,
|
||||||
HOST: String => "127.0.0.1".to_string(),
|
HOST: String => "127.0.0.1".to_string(),
|
||||||
|
|
||||||
|
DATABASE_URL < (
|
||||||
|
"postgres://",
|
||||||
|
POSTGRES_USERNAME => "user",
|
||||||
|
":",
|
||||||
|
POSTGRES_PASSWORD => "pass",
|
||||||
|
"@",
|
||||||
|
POSTGRES_HOST => "localhost:5432",
|
||||||
|
"/",
|
||||||
|
POSTGRES_DB => "test",
|
||||||
|
),
|
||||||
|
|
||||||
NAMESPACE {
|
NAMESPACE {
|
||||||
#[env_name = "MY_CUSTOM_NAME"]
|
#[env_name = "MY_CUSTOM_NAME"]
|
||||||
FOO: bool,
|
FOO: bool,
|
||||||
|
@ -37,8 +48,9 @@ fn main () {
|
||||||
env::set_var("MY_CUSTOM_NAME", "t");
|
env::set_var("MY_CUSTOM_NAME", "t");
|
||||||
|
|
||||||
cfg::init();
|
cfg::init();
|
||||||
assert_eq(cfg::HOST(), String::from("127.0.0.1"));
|
assert_eq!(cfg::HOST(), String::from("127.0.0.1"));
|
||||||
assert_eq(cfg::NAMESPACE::FOO(), true);
|
assert_eq!(cfg::DATABASE_URL(), String::from("postgres://user:pass@localhost:5432/test"));
|
||||||
|
assert_eq!(cfg::NAMESPACE::FOO(), true);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -55,7 +67,7 @@ cargo test
|
||||||
* [x] Custom env name
|
* [x] Custom env name
|
||||||
* [x] Support feature config and other meta directives
|
* [x] Support feature config and other meta directives
|
||||||
* [x] Add default value to env if env is not found
|
* [x] Add default value to env if env is not found
|
||||||
* [ ] Concat env variables to one variable
|
* [x] Concat env variables to one variable
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
|
@ -16,6 +16,17 @@ config! {
|
||||||
DEBUG: bool => true,
|
DEBUG: bool => true,
|
||||||
HOST: String => "127.0.0.1".to_string(),
|
HOST: String => "127.0.0.1".to_string(),
|
||||||
|
|
||||||
|
DATABASE_URL < (
|
||||||
|
"postgres://",
|
||||||
|
POSTGRES_USERNAME => "user",
|
||||||
|
":",
|
||||||
|
POSTGRES_PASSWORD => "pass",
|
||||||
|
"@",
|
||||||
|
POSTGRES_HOST => "localhost:5432",
|
||||||
|
"/",
|
||||||
|
POSTGRES_DB => "test",
|
||||||
|
),
|
||||||
|
|
||||||
NAMESPACE {
|
NAMESPACE {
|
||||||
#[env_name = "MY_CUSTOM_NAME"]
|
#[env_name = "MY_CUSTOM_NAME"]
|
||||||
FOO: bool,
|
FOO: bool,
|
||||||
|
@ -33,8 +44,9 @@ fn main () {
|
||||||
env::set_var("MY_CUSTOM_NAME", "t");
|
env::set_var("MY_CUSTOM_NAME", "t");
|
||||||
|
|
||||||
cfg::init();
|
cfg::init();
|
||||||
assert_eq(cfg::HOST(), String::from("127.0.0.1"));
|
assert_eq!(cfg::HOST(), String::from("127.0.0.1"));
|
||||||
assert_eq(cfg::NAMESPACE::FOO(), true);
|
assert_eq!(cfg::DATABASE_URL(), String::from("postgres://user:pass@localhost:5432/test"));
|
||||||
|
assert_eq!(cfg::NAMESPACE::FOO(), true);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -45,7 +57,7 @@ fn main () {
|
||||||
* [x] Custom env name
|
* [x] Custom env name
|
||||||
* [x] Support feature config and other meta directives
|
* [x] Support feature config and other meta directives
|
||||||
* [x] Add default value to env if env is not found
|
* [x] Add default value to env if env is not found
|
||||||
* [ ] Concat env variables to one variable
|
* [x] Concat env variables to one variable
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
//!
|
//!
|
||||||
//! cfg::init();
|
//! cfg::init();
|
||||||
//! assert_eq!(cfg::HOST(), String::from("127.0.0.1"));
|
//! assert_eq!(cfg::HOST(), String::from("127.0.0.1"));
|
||||||
//! assert_eq!(cfg::DATABASE_URL(), "postgres://user:pass@localhost:5432/test");
|
//! assert_eq!(cfg::DATABASE_URL(), String::from("postgres://user:pass@localhost:5432/test"));
|
||||||
//! assert_eq!(cfg::NAMESPACE::FOO(), true);
|
//! assert_eq!(cfg::NAMESPACE::FOO(), true);
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
Reference in a new issue