summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2021-11-23 14:38:27 +0000
committerConrad Ludgate <conradludgate@gmail.com>2021-11-23 14:39:22 +0000
commit1d776bba2cb62d851f7cbeda57dd45ec7cfaacd0 (patch)
tree55718ddb2787118593d158eb9c7c757a7673738e /examples
parent21526221aeb0c35c7e4cdbb631b431147bd54ed5 (diff)
fix config paths in examples
Diffstat (limited to 'examples')
-rw-r--r--examples/glob/main.rs14
-rw-r--r--examples/hierarchical-env/settings.rs6
-rw-r--r--examples/simple/main.rs2
-rw-r--r--examples/watch/main.rs4
4 files changed, 13 insertions, 13 deletions
diff --git a/examples/glob/main.rs b/examples/glob/main.rs
index 5e81f3c..5ba0f14 100644
--- a/examples/glob/main.rs
+++ b/examples/glob/main.rs
@@ -10,9 +10,9 @@ fn main() {
let mut settings = Config::default();
settings
// File::with_name(..) is shorthand for File::from(Path::new(..))
- .merge(File::with_name("conf/00-default.toml")).unwrap()
- .merge(File::from(Path::new("conf/05-some.yml"))).unwrap()
- .merge(File::from(Path::new("conf/99-extra.json"))).unwrap();
+ .merge(File::with_name("examples/glob/conf/00-default.toml")).unwrap()
+ .merge(File::from(Path::new("examples/glob/conf/05-some.yml"))).unwrap()
+ .merge(File::from(Path::new("examples/glob/conf/99-extra.json"))).unwrap();
// Print out our settings (as a HashMap)
println!("\n{:?} \n\n-----------",
@@ -23,9 +23,9 @@ fn main() {
// Gather all conf files from conf/ manually, but put in 1 merge call.
let mut settings = Config::default();
settings
- .merge(vec![File::with_name("conf/00-default.toml"),
- File::from(Path::new("conf/05-some.yml")),
- File::from(Path::new("conf/99-extra.json"))])
+ .merge(vec![File::with_name("examples/glob/conf/00-default.toml"),
+ File::from(Path::new("examples/glob/conf/05-some.yml")),
+ File::from(Path::new("examples/glob/conf/99-extra.json"))])
.unwrap();
// Print out our settings (as a HashMap)
@@ -37,7 +37,7 @@ fn main() {
// Gather all conf files from conf/ using glob and put in 1 merge call.
let mut settings = Config::default();
settings
- .merge(glob("conf/*")
+ .merge(glob("examples/glob/conf/*")
.unwrap()
.map(|path| File::from(path.unwrap()))
.collect::<Vec<_>>())
diff --git a/examples/hierarchical-env/settings.rs b/examples/hierarchical-env/settings.rs
index 7ef58b8..c701e31 100644
--- a/examples/hierarchical-env/settings.rs
+++ b/examples/hierarchical-env/settings.rs
@@ -41,17 +41,17 @@ impl Settings {
let mut s = Config::default();
// Start off by merging in the "default" configuration file
- s.merge(File::with_name("config/default"))?;
+ s.merge(File::with_name("examples/hierarchical-env/config/default"))?;
// Add in the current environment file
// Default to 'development' env
// Note that this file is _optional_
let env = env::var("RUN_MODE").unwrap_or_else(|_| "development".into());
- s.merge(File::with_name(&format!("config/{}", env)).required(false))?;
+ s.merge(File::with_name(&format!("examples/hierarchical-env/config/{}", env)).required(false))?;
// Add in a local configuration file
// This file shouldn't be checked in to git
- s.merge(File::with_name("config/local").required(false))?;
+ s.merge(File::with_name("examples/hierarchical-env/config/local").required(false))?;
// Add in settings from the environment (with a prefix of APP)
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
diff --git a/examples/simple/main.rs b/examples/simple/main.rs
index b38dcbf..4ae8c4f 100644
--- a/examples/simple/main.rs
+++ b/examples/simple/main.rs
@@ -4,7 +4,7 @@ fn main() {
let mut settings = config::Config::default();
settings
// Add in `./Settings.toml`
- .merge(config::File::with_name("Settings")).unwrap()
+ .merge(config::File::with_name("examples/simple/Settings")).unwrap()
// Add in settings from the environment (with a prefix of APP)
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
.merge(config::Environment::with_prefix("APP")).unwrap();
diff --git a/examples/watch/main.rs b/examples/watch/main.rs
index 9f3d21a..ac20997 100644
--- a/examples/watch/main.rs
+++ b/examples/watch/main.rs
@@ -8,7 +8,7 @@ use std::time::Duration;
lazy_static::lazy_static! {
static ref SETTINGS: RwLock<Config> = RwLock::new({
let mut settings = Config::default();
- settings.merge(File::with_name("Settings.toml")).unwrap();
+ settings.merge(File::with_name("examples/watch/Settings.toml")).unwrap();
settings
});
@@ -35,7 +35,7 @@ fn watch() {
// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
watcher
- .watch("./Settings.toml", RecursiveMode::NonRecursive)
+ .watch("examples/watch/Settings.toml", RecursiveMode::NonRecursive)
.unwrap();
// This is a simple loop, but you may want to use more complex logic here,