Skip to content

Commit

Permalink
Add fall back for artiaa_path if xdg_data_home is not defined (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
afujiwara-roblox committed Mar 5, 2024
1 parent 2774595 commit cfb0026
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default-members = [".", "artiaa_auth"]
[package]
name = "foreman"
description = "Toolchain manager for simple binary tools"
version = "1.6.0"
version = "1.6.1"
authors = [
"Lucien Greathouse <me@lpghatguy.com>",
"Matt Hargett <plaztiksyke@gmail.com>",
Expand Down
20 changes: 16 additions & 4 deletions src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,22 @@ fn get_artiaa_path_based_on_os() -> ForemanResult<PathBuf> {
let xdg_data_home = env::var("XDG_DATA_HOME").map_err(|_| ForemanError::EnvVarNotFound {
env_var: "$XDG_DATA_HOME".to_string(),
})?;
Ok(PathBuf::from(format!(
"{}/ArtiAA/artiaa-tokens.json",
xdg_data_home
)))

if let Ok(xdg_data_home) = env::var("XDG_DATA_HOME") {
return Ok(PathBuf::from(format!(
"{}/artiaa-tokens.json",
xdg_data_home
)));
} else if let Ok(home) = env::var("HOME") {
return Ok(PathBuf::from(format!(
"{}/.local/share/artiaa-tokens.json",
home
)));
} else {
return Err(ForemanError::EnvVarNotFound {
env_var: "$HOME".to_string(),
});
}
}

#[cfg(other)]
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/help_command.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: tests/cli.rs
assertion_line: 100
expression: content
---
foreman 1.6.0
foreman 1.6.1

USAGE:
foreman [FLAGS] <SUBCOMMAND>
Expand Down

0 comments on commit cfb0026

Please sign in to comment.