Skip to content

Commit 8ec82a7

Browse files
add config path to config struct
1 parent 2047926 commit 8ec82a7

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/config.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,25 @@ use serde::{Deserialize, Serialize};
1111
lazy_static! {
1212
pub static ref DIRS: ProjectDirs =
1313
ProjectDirs::from("me", "greenboi", "Papa").expect("Unable to find base dirs");
14-
pub static ref CONFIG: Config = Figment::from(Serialized::defaults(Config::default()))
15-
.merge(Toml::file(DIRS.config_dir().join("config.toml")))
16-
.merge(Env::prefixed("PAPA_"))
17-
.extract()
18-
.expect("Error reading configuration");
14+
pub static ref CONFIG: Config = {
15+
let path = DIRS.config_dir().join("config.toml");
16+
let mut cfg: Config = Figment::from(Serialized::defaults(Config::default()))
17+
.merge(Toml::file(&path))
18+
.merge(Env::prefixed("PAPA_"))
19+
.extract()
20+
.expect("Error reading configuration");
21+
cfg.config_path = Some(path);
22+
cfg
23+
};
1924
}
2025

2126
#[derive(Serialize, Deserialize, Debug, Clone)]
2227
pub struct Config {
2328
game_dir: Option<PathBuf>,
2429
install_dir: PathBuf,
2530
is_server: bool,
31+
#[serde(skip)]
32+
pub config_path: Option<PathBuf>,
2633
}
2734

2835
impl Config {
@@ -57,6 +64,7 @@ impl Default for Config {
5764
game_dir: None,
5865
install_dir: "./mods".into(),
5966
is_server: false,
67+
config_path: None,
6068
}
6169
}
6270
}

src/core/commands/env.rs

+5
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ pub fn env() -> Result<()> {
1515
"Cache directory: {}",
1616
DIRS.cache_dir().display().bright_cyan()
1717
);
18+
19+
if let Some(path) = &CONFIG.config_path {
20+
println!("\nConfig file: {}", path.display().bright_cyan());
21+
}
22+
1823
Ok(())
1924
}

0 commit comments

Comments
 (0)