Skip to content

Commit 3544073

Browse files
committed
Remove feature gates and full move to XDG and etcetera
1 parent 45bfa32 commit 3544073

File tree

2 files changed

+12
-40
lines changed

2 files changed

+12
-40
lines changed

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "confy"
3-
version = "1.0.0"
3+
version = "2.0.0"
44
authors = ["Katharina Fey <[email protected]>"]
55
description = "Boilerplate-free configuration management"
66
license = "MIT/X11 OR Apache-2.0"
@@ -16,15 +16,14 @@ serde = "^1.0"
1616
serde_yaml = { version = "0.9", optional = true }
1717
thiserror = "2.0"
1818
basic-toml = { version = "0.1.10", optional = true }
19-
toml = { version = "0.8", optional = true }
19+
toml = { version = "0.9", optional = true }
2020

2121
[features]
2222
default = ["toml_conf"]
2323
toml_conf = ["toml"]
2424
basic_toml_conf = ["basic-toml"]
2525
yaml_conf = ["serde_yaml"]
2626
ron_conf = ["ron"]
27-
xdg = []
2827

2928
[[example]]
3029
name = "simple"

src/lib.rs

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@
9494
mod utils;
9595
use utils::*;
9696

97-
#[cfg(feature = "xdg")]
98-
use etcetera::app_strategy::choose_app_strategy;
99-
#[cfg(not(feature = "xdg"))]
100-
use etcetera::app_strategy::choose_native_strategy;
101-
use etcetera::{AppStrategy, AppStrategyArgs};
97+
use etcetera::{AppStrategy, AppStrategyArgs, app_strategy::choose_app_strategy};
10298
use serde::{Serialize, de::DeserializeOwned};
10399
use std::fs::{self, File, OpenOptions, Permissions};
104100
use std::io::{ErrorKind::NotFound, Write};
@@ -473,31 +469,14 @@ pub fn get_configuration_file_path<'a>(
473469
config_name: impl Into<Option<&'a str>>,
474470
) -> Result<PathBuf, ConfyError> {
475471
let config_name = config_name.into().unwrap_or("default-config");
476-
let project;
477-
478-
#[cfg(not(feature = "xdg"))]
479-
{
480-
project = choose_native_strategy(AppStrategyArgs {
481-
top_level_domain: "rs".to_string(),
482-
author: "".to_string(),
483-
app_name: app_name.to_string(),
484-
})
485-
.map_err(|e| {
486-
ConfyError::BadConfigDirectory(format!("could not determine home directory path: {e}"))
487-
})?;
488-
}
489-
490-
#[cfg(feature = "xdg")]
491-
{
492-
project = choose_app_strategy(AppStrategyArgs {
493-
top_level_domain: "rs".to_string(),
494-
author: "".to_string(),
495-
app_name: app_name.to_string(),
496-
})
497-
.map_err(|e| {
498-
ConfyError::BadConfigDirectory(format!("could not determine home directory path: {e}"))
499-
})?;
500-
}
472+
let project = choose_app_strategy(AppStrategyArgs {
473+
top_level_domain: "rs".to_string(),
474+
author: "".to_string(),
475+
app_name: app_name.to_string(),
476+
})
477+
.map_err(|e| {
478+
ConfyError::BadConfigDirectory(format!("could not determine home directory path: {e}"))
479+
})?;
501480

502481
let config_dir_str = get_configuration_directory_str(&project)?;
503482

@@ -509,13 +488,7 @@ pub fn get_configuration_file_path<'a>(
509488
}
510489

511490
fn get_configuration_directory_str(project: &impl AppStrategy) -> Result<String, ConfyError> {
512-
let path = if cfg!(feature = "xdg") {
513-
project.config_dir()
514-
} else {
515-
project.data_dir()
516-
};
517-
518-
Ok(format!("{}", path.display()))
491+
Ok(project.config_dir().display().to_string())
519492
}
520493

521494
#[cfg(test)]

0 commit comments

Comments
 (0)