Skip to content

Commit

Permalink
Fix config example
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Dec 19, 2022
1 parent 0d17600 commit aed9bd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 4 additions & 2 deletions examples/cli/config/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use serde::Deserialize;

fn main() {
App::new()
.add_plugin(ConfigPlugin::new())
.add_plugin(ConfigPlugin::<Config>::with_default_str(include_str!(
"config/default.toml"
)))
.add_startup_system_to_stage(ConfigStartupStage::Setup, add_custom_sources)
.add_system(log_config)
.run();
Expand All @@ -23,7 +25,7 @@ fn log_config(config: Res<Config>) {
println!("{:#?}", *config);
}

#[derive(ConfigPlugin, Debug, Deserialize)]
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
pub struct Config {
base_url: String,
Expand Down
11 changes: 5 additions & 6 deletions plugins/bundle/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use config::{
builder::{ConfigBuilder, DefaultState},
File,
};
use dip_core::{config::ConfigPlugin as ConfigPluginRaw, prelude::ConfigStartupStage};
use dip_core::{config::ConfigPlugin, prelude::ConfigStartupStage};
use reqwest::Url;
use serde::{de, Deserialize, Deserializer};
use std::{fs, path::PathBuf};
Expand All @@ -17,14 +17,14 @@ pub struct BundleConfigPlugin;

impl Plugin for BundleConfigPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(ConfigPluginRaw::<BundleConfig>::with_default_str(
app.add_plugin(ConfigPlugin::<BundleConfig>::with_default_str(
include_str!("config/default.toml"),
))
.add_startup_system_to_stage(ConfigStartupStage::Setup, add_sources);
.add_startup_system_to_stage(ConfigStartupStage::Setup, add_user_config);
}
}

fn add_sources(mut builder: ResMut<ConfigBuilder<DefaultState>>) {
fn add_user_config(mut builder: ResMut<ConfigBuilder<DefaultState>>) {
let config_file_path = BundleConfig::config_file_path();

if config_file_path.is_file() {
Expand Down Expand Up @@ -75,8 +75,7 @@ pub struct BundleConfig {

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

p
}
Expand Down

1 comment on commit aed9bd7

@vercel
Copy link

@vercel vercel bot commented on aed9bd7 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

dip – ./

dip-diptools.vercel.app
dip-git-main-diptools.vercel.app
dip.tools

Please sign in to comment.