From 7bdf13f53eb25d4e0f3d51ccb4aa57e74f6b8be7 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 7 Jan 2020 16:17:48 +0300 Subject: [PATCH] doc: update readme --- README.md | 18 +++++++++++++++--- itconfig/README.md | 18 +++++++++++++++--- itconfig/src/lib.rs | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 71a1ad5..fc6d1a6 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,17 @@ config! { DEBUG: bool => true, 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 { #[env_name = "MY_CUSTOM_NAME"] FOO: bool, @@ -37,8 +48,9 @@ fn main () { env::set_var("MY_CUSTOM_NAME", "t"); cfg::init(); - assert_eq(cfg::HOST(), String::from("127.0.0.1")); - assert_eq(cfg::NAMESPACE::FOO(), true); + assert_eq!(cfg::HOST(), String::from("127.0.0.1")); + 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] Support feature config and other meta directives * [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 diff --git a/itconfig/README.md b/itconfig/README.md index a7c6cc7..7ab51fa 100644 --- a/itconfig/README.md +++ b/itconfig/README.md @@ -16,6 +16,17 @@ config! { DEBUG: bool => true, 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 { #[env_name = "MY_CUSTOM_NAME"] FOO: bool, @@ -33,8 +44,9 @@ fn main () { env::set_var("MY_CUSTOM_NAME", "t"); cfg::init(); - assert_eq(cfg::HOST(), String::from("127.0.0.1")); - assert_eq(cfg::NAMESPACE::FOO(), true); + assert_eq!(cfg::HOST(), String::from("127.0.0.1")); + 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] Support feature config and other meta directives * [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 diff --git a/itconfig/src/lib.rs b/itconfig/src/lib.rs index bb76097..d100b80 100644 --- a/itconfig/src/lib.rs +++ b/itconfig/src/lib.rs @@ -39,7 +39,7 @@ //! //! cfg::init(); //! 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); //! } //! ```