Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust }}

- name: Run cargo test
run: cargo test
run: cargo test -- --test-threads=1
shell: bash

clippy:
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "confy"
version = "1.0.0"
version = "2.0.0"
authors = ["Katharina Fey <[email protected]>"]
description = "Boilerplate-free configuration management"
license = "MIT/X11 OR Apache-2.0"
Expand All @@ -11,12 +11,13 @@ edition = "2024"

[dependencies]
ron = { version = "0.10.1", optional = true }
directories = "6"
etcetera = "0.10.0"
serde = "^1.0"
serde_yaml = { version = "0.9", optional = true }
thiserror = "2.0"
basic-toml = { version = "0.1.10", optional = true }
toml = { version = "0.8", optional = true }
toml = { version = "0.9", optional = true }
lazy_static = "1.5"

[features]
default = ["toml_conf"]
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,36 @@ Information about adding context to error messages can be found at [Providing Co

## Config File Location

`confy` uses [ProjectDirs](https://github.com/dirs-dev/directories-rs?tab=readme-ov-file#projectdirs) to store your configuration files, the common locations for those are in the `config_dir` section, below are the common OS paths:
`confy` uses the [etcetera](https://docs.rs/etcetera/latest/etcetera/) crate to store your configuration files, the common locations for those depend on the stratgey usd [`App Strategy`](https://docs.rs/etcetera/latest/etcetera/#appstrategy) or [`Native Strategy`](https://docs.rs/etcetera/latest/etcetera/#native-strategy), below are the common OS paths, you can change the strategy using the built-in [`change_config_strategy`](https://docs.rs/confy/2.0.0/confy/fn.change_config_strategy.html) function.

### App Strategy

This is the default strategy in version `2.0.0`+. It uses the `XDG` format on both Linux and MacOS systems.

| Linux | macOS | Windows |
| --- | --- | --- |
| `$XDG_CONFIG_HOME`/`<project_path>` or `$HOME`/.config/`<project_path>` | `$HOME`/.config/`<project_path>` | `{FOLDERID_RoamingAppData}`/`<project_path>`/config |

Where the `<project_path>` will be `$MY_APP_NAME`.

### Native Strategy

You can change to this strategy which is provided for both backwards capability and for GUI applications on macOS which is more traditional and expects this format.

| Linux | macOS | Windows |
| --- | --- | --- |
| `$XDG_CONFIG_HOME`/`<project_path>` or `$HOME`/.config/`<project_path>` | `$HOME`/Library/Application Support/`<project_path>` | `{FOLDERID_RoamingAppData}`/`<project_path>`/config |

Where the `<project_path>` will be `rs.$MY_APP_NAME`.
Where the `<project_path>` will be `rs.$MY_APP_NAME` on macOS and just `$MY_APP_NAME` elsewhere.

## Breaking changes

### Version 2.0.0

In version `2.0.0` we moved from the [`ProjectDirs`](https://github.com/dirs-dev/directories-rs?tab=readme-ov-file#projectdirs) crate to [`etcetera`](https://docs.rs/etcetera/latest/etcetera/) allowing for both uses of `XDG` or the OS's Native paths.

* From now on the default will be using `XDG` directories on macOS.

### Version 0.6.0

In this version we bumped several dependencies which have had changes with some of the default (de)serialization process:
Expand Down
5 changes: 2 additions & 3 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> Result<(), confy::ConfyError> {
name: "Test".to_string(),
..cfg
};
confy::store("confy_simple_app",None, &cfg)?;
confy::store("confy_simple_app", None, &cfg)?;
println!("The updated toml file content is:");
let mut content = String::new();
std::fs::File::open(&file)
Expand All @@ -53,7 +53,6 @@ fn main() -> Result<(), confy::ConfyError> {
name: "Test".to_string(),
..cfg
};
std::fs::remove_dir_all(file.parent().unwrap())
.expect("Failed to remove directory");
std::fs::remove_dir_all(file.parent().unwrap()).expect("Failed to remove directory");
Ok(())
}
Loading
Loading