diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-05-22 09:47:49 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-05-22 09:47:49 +0200 |
| commit | 77f51e690b26346ff4b251c27eb2ece493820d85 (patch) | |
| tree | cc7d2383d504ac041f2f1fa3acc1a703acbaff3f | |
| parent | 23e5b4adac9b73b268f41dd5d9e0e783dd411033 (diff) | |
| parent | 30b1234cf4e2d9a8ab257857fe0c2305f74a4d74 (diff) | |
| download | mullvadvpn-77f51e690b26346ff4b251c27eb2ece493820d85.tar.xz mullvadvpn-77f51e690b26346ff4b251c27eb2ece493820d85.zip | |
Merge branch 'fix-cli-privkey-input'
| -rw-r--r-- | mullvad-cli/src/cmds/account.rs | 12 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/relay.rs | 3 |
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 |
