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
-rw-r--r--mullvad-cli/src/cmds/relay.rs3
2 files changed, 13 insertions, 2 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()
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index 37b86537e4..9ddc86e5ba 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -360,7 +360,8 @@ impl Relay {
let private_key_str = tokio::task::spawn_blocking(|| {
let mut private_key_str = String::new();
let _ = std::io::stdin().lock().read_line(&mut private_key_str);
- if private_key_str.trim().is_empty() {
+ let private_key_str = private_key_str.trim().to_owned();
+ if private_key_str.is_empty() {
eprintln!("Expected to read private key from standard input");
}
private_key_str