Skip to content

Commit

Permalink
chore: rearrange env_utils functions
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Jul 20, 2024
1 parent f3aae1f commit 5d729f5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/utils/src/env_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ pub fn get_env_var(key: &str) -> Result<String, VarError> {
std::env::var(key)
}

pub fn get_env_var_or_panic(key: &str) -> String {
get_env_var(key).unwrap_or_else(|e| panic!("Failed to get env var {}: {}", key, e))
}

pub fn get_env_var_or_default(key: &str, default: &str) -> String {
get_env_var(key).unwrap_or(default.to_string())
}

pub fn get_env_var_optional(key: &str) -> Result<Option<String>, VarError> {
match get_env_var(key) {
Ok(s) => Ok(Some(s)),
Expand All @@ -15,11 +23,3 @@ pub fn get_env_var_optional(key: &str) -> Result<Option<String>, VarError> {
pub fn get_env_car_optional_or_panic(key: &str) -> Option<String> {
get_env_var_optional(key).unwrap_or_else(|e| panic!("Failed to get env var {}: {}", key, e))
}

pub fn get_env_var_or_panic(key: &str) -> String {
get_env_var(key).unwrap_or_else(|e| panic!("Failed to get env var {}: {}", key, e))
}

pub fn get_env_var_or_default(key: &str, default: &str) -> String {
get_env_var(key).unwrap_or(default.to_string())
}

0 comments on commit 5d729f5

Please sign in to comment.