diff --git a/src/config.rs b/src/config.rs index 024656c..0a32bf9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,6 +18,7 @@ impl Configuration { let mut settings = config::Config::default(); let mut location: Vec = Vec::new(); + // TODO: add condition for target os location.push("config.json".to_string()); location.push("/etc/gt/config.json".to_string()); location.push(format!("{}/.config/gt/config.json", home_dir_env)); @@ -28,8 +29,42 @@ impl Configuration { .unwrap(); } - let config = settings.try_into::().expect("Couldn't load config into gt!"); + let config = settings + .try_into::() + .expect("Couldn't load config into gt!"); config } } + +#[cfg(target_os = "linux")] +fn set_location_linux( + location: &mut Vec, + home: String + ) -> Vec { + location.push("config.json".to_string()); + location.push("/etc/gt/config.json".to_string()); + location.push(format!("{}/.config/gt/config.json", home)); + + location.to_vec() +} + +#[cfg(target_os = "macos")] +fn set_location_macos( + location: &mut Vec, + home: String + ) -> Vec { + location.push("config.json".to_string()); + + location.to_vec() +} + +#[cfg(target_os = "windows")] +fn set_location_windows( + location: &mut Vec, + home: String + ) -> Vec { + location.push("config.json".to_string()); + + location.to_vec() +} \ No newline at end of file