Skip to content

Commit aed9bd7

Browse files
Fix config example
1 parent 0d17600 commit aed9bd7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

examples/cli/config/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use serde::Deserialize;
77

88
fn main() {
99
App::new()
10-
.add_plugin(ConfigPlugin::new())
10+
.add_plugin(ConfigPlugin::<Config>::with_default_str(include_str!(
11+
"config/default.toml"
12+
)))
1113
.add_startup_system_to_stage(ConfigStartupStage::Setup, add_custom_sources)
1214
.add_system(log_config)
1315
.run();
@@ -23,7 +25,7 @@ fn log_config(config: Res<Config>) {
2325
println!("{:#?}", *config);
2426
}
2527

26-
#[derive(ConfigPlugin, Debug, Deserialize)]
28+
#[derive(Debug, Deserialize)]
2729
#[allow(dead_code)]
2830
pub struct Config {
2931
base_url: String,

plugins/bundle/src/config.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use config::{
88
builder::{ConfigBuilder, DefaultState},
99
File,
1010
};
11-
use dip_core::{config::ConfigPlugin as ConfigPluginRaw, prelude::ConfigStartupStage};
11+
use dip_core::{config::ConfigPlugin, prelude::ConfigStartupStage};
1212
use reqwest::Url;
1313
use serde::{de, Deserialize, Deserializer};
1414
use std::{fs, path::PathBuf};
@@ -17,14 +17,14 @@ pub struct BundleConfigPlugin;
1717

1818
impl Plugin for BundleConfigPlugin {
1919
fn build(&self, app: &mut App) {
20-
app.add_plugin(ConfigPluginRaw::<BundleConfig>::with_default_str(
20+
app.add_plugin(ConfigPlugin::<BundleConfig>::with_default_str(
2121
include_str!("config/default.toml"),
2222
))
23-
.add_startup_system_to_stage(ConfigStartupStage::Setup, add_sources);
23+
.add_startup_system_to_stage(ConfigStartupStage::Setup, add_user_config);
2424
}
2525
}
2626

27-
fn add_sources(mut builder: ResMut<ConfigBuilder<DefaultState>>) {
27+
fn add_user_config(mut builder: ResMut<ConfigBuilder<DefaultState>>) {
2828
let config_file_path = BundleConfig::config_file_path();
2929

3030
if config_file_path.is_file() {
@@ -75,8 +75,7 @@ pub struct BundleConfig {
7575

7676
impl BundleConfig {
7777
pub fn config_file_path() -> PathBuf {
78-
let p = Config::config_dir().join("bundle");
79-
Config::ensure_dir(&p);
78+
let p = Config::config_dir().join("bundle.toml");
8079

8180
p
8281
}

0 commit comments

Comments
 (0)