Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #225 from AaronO/improvement/make-global-config-op…
Browse files Browse the repository at this point in the history
…tional

Settings: make global config file optional
  • Loading branch information
ashleygwilliams authored Jul 29, 2019
2 parents c1a646a + 0efeee0 commit 06a29a4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/settings/global_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ fn get_global_config() -> Result<GlobalUser, failure::Error> {
let config_str = config_path
.to_str()
.expect("global config path should be a string");
s.merge(File::with_name(config_str))?;

// Eg.. `CF_ACCOUNT_AUTH_KEY=farts` would set the `account_auth_key` key
// Skip reading global config if non existent
// because envs might be provided
if config_path.exists() {
s.merge(File::with_name(config_str))?;
}

// Eg.. `CF_API_KEY=farts` would set the `account_auth_key` key
// envs are: CF_API_KEY and CF_EMAIL
s.merge(Environment::with_prefix("CF"))?;

let global_user: Result<GlobalUser, config::ConfigError> = s.try_into();
Expand Down

0 comments on commit 06a29a4

Please sign in to comment.