Skip to content

Commit

Permalink
cli: improve default config dir on unix with XDG spec
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed Jul 4, 2024
1 parent 07744e5 commit 550c845
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# v0.2.2 (2024-07-04)

- improve handling of default xdg config dir (unix only)
- fix typos

# v0.2.1 (2024-07-04)
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ fn fetch_all_results(username: &str, host: &str, token: &str) -> Response {
fn config_file_path() -> Result<PathBuf, Box<dyn Error>> {
#[cfg(target_family = "unix")]
let config_os_dir = {
let home = std::env::var("HOME")?;
// First look for XDG_CONFIG_HOME, then fall back to HOME
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
let home = std::env::var("XDG_CONFIG_HOME").unwrap_or(std::env::var("HOME")?);
PathBuf::from(home).join(".config")
};
#[cfg(target_family = "windows")]
Expand Down

0 comments on commit 550c845

Please sign in to comment.