Skip to content

Commit cfb0026

Browse files
Add fall back for artiaa_path if xdg_data_home is not defined (#92)
1 parent 2774595 commit cfb0026

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ default-members = [".", "artiaa_auth"]
66
[package]
77
name = "foreman"
88
description = "Toolchain manager for simple binary tools"
9-
version = "1.6.0"
9+
version = "1.6.1"
1010
authors = [
1111
"Lucien Greathouse <me@lpghatguy.com>",
1212
"Matt Hargett <plaztiksyke@gmail.com>",

src/paths.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,22 @@ fn get_artiaa_path_based_on_os() -> ForemanResult<PathBuf> {
127127
let xdg_data_home = env::var("XDG_DATA_HOME").map_err(|_| ForemanError::EnvVarNotFound {
128128
env_var: "$XDG_DATA_HOME".to_string(),
129129
})?;
130-
Ok(PathBuf::from(format!(
131-
"{}/ArtiAA/artiaa-tokens.json",
132-
xdg_data_home
133-
)))
130+
131+
if let Ok(xdg_data_home) = env::var("XDG_DATA_HOME") {
132+
return Ok(PathBuf::from(format!(
133+
"{}/artiaa-tokens.json",
134+
xdg_data_home
135+
)));
136+
} else if let Ok(home) = env::var("HOME") {
137+
return Ok(PathBuf::from(format!(
138+
"{}/.local/share/artiaa-tokens.json",
139+
home
140+
)));
141+
} else {
142+
return Err(ForemanError::EnvVarNotFound {
143+
env_var: "$HOME".to_string(),
144+
});
145+
}
134146
}
135147

136148
#[cfg(other)]

tests/snapshots/help_command.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: tests/cli.rs
33
assertion_line: 100
44
expression: content
55
---
6-
foreman 1.6.0
6+
foreman 1.6.1
77

88
USAGE:
99
foreman [FLAGS] <SUBCOMMAND>

0 commit comments

Comments
 (0)