diff options
| author | Peter Brunner <peter@lugoues.net> | 2023-06-12 12:58:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-12 16:58:46 +0000 |
| commit | a6da5340e7f034ca66c4130d0be6799d59eb19c3 (patch) | |
| tree | 9cd6929afd7bca75700239b1cb0039970a526be3 /atuin-client/src/api_client.rs | |
| parent | refactor server to allow pluggable db and tracing (#1036) (diff) | |
| download | atuin-a6da5340e7f034ca66c4130d0be6799d59eb19c3.zip | |
add support to override hostname and username via env var (#1041)
Diffstat (limited to 'atuin-client/src/api_client.rs')
| -rw-r--r-- | atuin-client/src/api_client.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs index 5ea84b9d..2510d197 100644 --- a/atuin-client/src/api_client.rs +++ b/atuin-client/src/api_client.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use std::collections::HashSet; +use std::env; use chrono::Utc; use eyre::{bail, Result}; @@ -161,10 +162,13 @@ impl<'a> Client<'a> { host: Option<String>, deleted: HashSet<String>, ) -> Result<Vec<History>> { - let host = match host { - None => hash_str(&format!("{}:{}", whoami::hostname(), whoami::username())), - Some(h) => h, - }; + let host = host.unwrap_or_else(|| { + hash_str(&format!( + "{}:{}", + env::var("ATUIN_HOST_NAME").unwrap_or_else(|_| whoami::hostname()), + env::var("ATUIN_HOST_USER").unwrap_or_else(|_| whoami::username()) + )) + }); let url = format!( "{}/sync/history?sync_ts={}&history_ts={}&host={}", |
