summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-cli/src')
-rw-r--r--mullvad-cli/src/cmds/account.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/mullvad-cli/src/cmds/account.rs b/mullvad-cli/src/cmds/account.rs
index d46469484f..7faf0856e1 100644
--- a/mullvad-cli/src/cmds/account.rs
+++ b/mullvad-cli/src/cmds/account.rs
@@ -65,7 +65,7 @@ impl Account {
Account::Login { account } => {
Self::login(
&mut rpc,
- account.unwrap_or_else(|| from_stdin("Enter an account number: ")),
+ unwrap_or_from_stdin(account, "Enter an account number: ").await,
)
.await
}
@@ -217,6 +217,16 @@ async fn account_else_current(
}
}
+async fn unwrap_or_from_stdin(val: Option<String>, prompt_str: &'static str) -> String {
+ if let Some(val) = val {
+ return val;
+ }
+
+ tokio::task::spawn_blocking(|| from_stdin(prompt_str))
+ .await
+ .unwrap()
+}
+
fn from_stdin(prompt_str: &'static str) -> String {
let mut val = String::new();
io::stdout()