Skip to content

Commit

Permalink
fix: Config paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Mar 2, 2024
1 parent d61375b commit c6567df
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/configuration/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,24 @@ impl Config {

let default_backend = BackendName::Ollama.to_string();
let default_editor = EditorName::Clipboard.to_string();
// MacOS default.
let mut config_path = path::PathBuf::from(env::var("HOME").unwrap());
config_path = config_path.join(".config/oatmeal/config.toml");

#[cfg(not(target_os = "macos"))]
let mut config_path = dirs::cache_dir().unwrap().join("oatmeal/config.toml");
if !config_path.exists() {
config_path = dirs::config_local_dir()
.unwrap()
.join("oatmeal/config.toml");
#[cfg(target_os = "windows")]
{
config_path = dirs::cache_dir().unwrap().join("oatmeal/config.toml");
}

#[cfg(target_os = "linux")]
{
config_path = dirs::cache_dir().unwrap().join("oatmeal/config.toml");
if !config_path.exists() {
config_path = dirs::config_local_dir()
.unwrap()
.join("oatmeal/config.toml");
}
}
#[cfg(target_os = "macos")]
let config_path =
path::PathBuf::from(env::var("HOME").unwrap()).join(".config/oatmeal/config.toml");

let res = match key {
ConfigKey::Backend => &default_backend,
Expand Down

0 comments on commit c6567df

Please sign in to comment.