File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,25 @@ use serde::{Deserialize, Serialize};
11
11
lazy_static ! {
12
12
pub static ref DIRS : ProjectDirs =
13
13
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
+ } ;
19
24
}
20
25
21
26
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
22
27
pub struct Config {
23
28
game_dir : Option < PathBuf > ,
24
29
install_dir : PathBuf ,
25
30
is_server : bool ,
31
+ #[ serde( skip) ]
32
+ pub config_path : Option < PathBuf > ,
26
33
}
27
34
28
35
impl Config {
@@ -57,6 +64,7 @@ impl Default for Config {
57
64
game_dir : None ,
58
65
install_dir : "./mods" . into ( ) ,
59
66
is_server : false ,
67
+ config_path : None ,
60
68
}
61
69
}
62
70
}
Original file line number Diff line number Diff line change @@ -15,5 +15,10 @@ pub fn env() -> Result<()> {
15
15
"Cache directory: {}" ,
16
16
DIRS . cache_dir( ) . display( ) . bright_cyan( )
17
17
) ;
18
+
19
+ if let Some ( path) = & CONFIG . config_path {
20
+ println ! ( "\n Config file: {}" , path. display( ) . bright_cyan( ) ) ;
21
+ }
22
+
18
23
Ok ( ( ) )
19
24
}
You can’t perform that action at this time.
0 commit comments