1+ use crate :: touch:: TriggerCorner ;
12use anyhow:: Result ;
2- use figment:: { Figment , providers:: { Env , Toml , Serialized , Format } } ;
3+ use figment:: {
4+ providers:: { Env , Format , Serialized , Toml } ,
5+ Figment ,
6+ } ;
37use serde:: { Deserialize , Serialize } ;
4- use crate :: touch:: TriggerCorner ;
58
69#[ derive( Serialize , Deserialize , Debug , Clone ) ]
710pub struct Config {
@@ -86,19 +89,16 @@ impl Config {
8689 let config_path = Self :: config_path ( ) ?;
8790
8891 log:: info!( "Saving config to {:?}" , config_path) ;
89- let content = toml:: to_string_pretty ( self )
90- . map_err ( |e| anyhow:: anyhow!( "Failed to serialize config: {}" , e) ) ?;
92+ let content = toml:: to_string_pretty ( self ) . map_err ( |e| anyhow:: anyhow!( "Failed to serialize config: {}" , e) ) ?;
9193
92- std:: fs:: write ( & config_path, content)
93- . map_err ( |e| anyhow:: anyhow!( "Failed to write config file {:?}: {}" , config_path, e) ) ?;
94+ std:: fs:: write ( & config_path, content) . map_err ( |e| anyhow:: anyhow!( "Failed to write config file {:?}: {}" , config_path, e) ) ?;
9495
9596 Ok ( ( ) )
9697 }
9798
9899 /// Get the config file path: ~/.ghostwriter.toml
99100 pub fn config_path ( ) -> Result < std:: path:: PathBuf > {
100- let home = std:: env:: var ( "HOME" )
101- . map_err ( |_| anyhow:: anyhow!( "HOME environment variable not set" ) ) ?;
101+ let home = std:: env:: var ( "HOME" ) . map_err ( |_| anyhow:: anyhow!( "HOME environment variable not set" ) ) ?;
102102 Ok ( std:: path:: Path :: new ( & home) . join ( ".ghostwriter.toml" ) )
103103 }
104104
@@ -109,7 +109,7 @@ impl Config {
109109
110110 // Validate log level
111111 match self . log_level . as_str ( ) {
112- "error" | "warn" | "info" | "debug" | "trace" => { } ,
112+ "error" | "warn" | "info" | "debug" | "trace" => { }
113113 _ => return Err ( anyhow:: anyhow!( "Invalid log level: {}" , self . log_level) ) ,
114114 }
115115
@@ -120,4 +120,4 @@ impl Config {
120120
121121 Ok ( ( ) )
122122 }
123- }
123+ }
0 commit comments