diff options
Diffstat (limited to 'src/command/client/sync/login.rs')
| -rw-r--r-- | src/command/client/sync/login.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/command/client/sync/login.rs b/src/command/client/sync/login.rs index 8056d1bb..29222563 100644 --- a/src/command/client/sync/login.rs +++ b/src/command/client/sync/login.rs @@ -6,6 +6,7 @@ use tokio::{fs::File, io::AsyncWriteExt}; use atuin_client::{api_client, settings::Settings}; use atuin_common::api::LoginRequest; +use rpassword::prompt_password; #[derive(Parser)] #[clap(setting(AppSettings::DeriveDisplayOrder))] @@ -40,9 +41,8 @@ impl Cmd { } let username = or_user_input(&self.username, "username"); - let password = or_user_input(&self.password, "password"); let key = or_user_input(&self.key, "encryption key"); - + let password = self.password.clone().unwrap_or_else(read_user_password); let session = api_client::login( settings.sync_address.as_str(), LoginRequest { username, password }, @@ -67,6 +67,11 @@ pub(super) fn or_user_input(value: &'_ Option<String>, name: &'static str) -> St value.clone().unwrap_or_else(|| read_user_input(name)) } +pub(super) fn read_user_password() -> String { + let password = prompt_password("Please enter password: "); + password.expect("Failed to read from input") +} + fn read_user_input(name: &'static str) -> String { eprint!("Please enter {}: ", name); get_input().expect("Failed to read from input") |
