From 944099594000e9d424fff5dc884d8b4e7541c408 Mon Sep 17 00:00:00 2001 From: Aiden Fujiwara Date: Tue, 5 Mar 2024 13:06:19 -0800 Subject: [PATCH 1/4] add fall back if xdg_data_home is not defined --- src/paths.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/paths.rs b/src/paths.rs index 2c8de9e..ecc55f0 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -127,10 +127,16 @@ fn get_artiaa_path_based_on_os() -> ForemanResult { 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)] From faf485a0a15aaebd328ad0ceaccab8bb82870227 Mon Sep 17 00:00:00 2001 From: Aiden Fujiwara Date: Tue, 5 Mar 2024 13:08:07 -0800 Subject: [PATCH 2/4] cargo fmt --- src/paths.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/paths.rs b/src/paths.rs index ecc55f0..69a1b65 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -129,9 +129,15 @@ fn get_artiaa_path_based_on_os() -> ForemanResult { })?; if let Ok(xdg_data_home) = env::var("XDG_DATA_HOME") { - return Ok(PathBuf::from(format!("{}/artiaa-tokens.json", 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))); + return Ok(PathBuf::from(format!( + "{}/.local/share/artiaa-tokens.json", + home + ))); } else { return Err(ForemanError::EnvVarNotFound { env_var: "$HOME".to_string(), From bbabdd84a7a76877e1b9c0866de6bacde723aac6 Mon Sep 17 00:00:00 2001 From: Aiden Fujiwara Date: Tue, 5 Mar 2024 13:19:37 -0800 Subject: [PATCH 3/4] bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b85d3f..593c976 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,7 +390,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "foreman" -version = "1.6.0" +version = "1.6.1" dependencies = [ "artiaa_auth", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index cdb1834..4e12007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 ", "Matt Hargett ", From e48efdb66b643e8bed8ccf8403cb5541c32954c7 Mon Sep 17 00:00:00 2001 From: Aiden Fujiwara Date: Tue, 5 Mar 2024 13:33:14 -0800 Subject: [PATCH 4/4] update snapshot --- tests/snapshots/help_command.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/snapshots/help_command.snap b/tests/snapshots/help_command.snap index 6abdecf..2fdb011 100644 --- a/tests/snapshots/help_command.snap +++ b/tests/snapshots/help_command.snap @@ -3,7 +3,7 @@ source: tests/cli.rs assertion_line: 100 expression: content --- -foreman 1.6.0 +foreman 1.6.1 USAGE: foreman [FLAGS]