Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fall back for artiaa_path if xdg_data_home is not defined #92

Merged
merged 4 commits into from
Mar 5, 2024
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 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 <[email protected]>",
"Matt Hargett <[email protected]>",
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
Loading