diff options
| author | Conrad Ludgate <conradludgate@gmail.com> | 2021-12-08 13:37:49 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-08 13:37:49 +0000 |
| commit | 4bdf4c40c292b681452c9499b9072b759073bf32 (patch) | |
| tree | 1eddc50584485efbec2c1ab8e470844d25de12df /src/command/login.rs | |
| parent | Remove dev dep with wildcard (#224) (diff) | |
| download | atuin-4bdf4c40c292b681452c9499b9072b759073bf32.zip | |
feat: login/register no longer blocking (#216)
Diffstat (limited to 'src/command/login.rs')
| -rw-r--r-- | src/command/login.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/command/login.rs b/src/command/login.rs index c4817a5f..63a3e0ec 100644 --- a/src/command/login.rs +++ b/src/command/login.rs @@ -1,10 +1,10 @@ +use std::borrow::Cow; use std::io; -use std::io::prelude::*; -use std::{borrow::Cow, fs::File}; use atuin_common::api::LoginRequest; use eyre::Result; use structopt::StructOpt; +use tokio::{fs::File, io::AsyncWriteExt}; use atuin_client::api_client; use atuin_client::settings::Settings; @@ -29,7 +29,7 @@ fn get_input() -> Result<String> { } impl Cmd { - pub fn run(&self, settings: &Settings) -> Result<()> { + pub async fn run(&self, settings: &Settings) -> Result<()> { let session_path = atuin_common::utils::data_dir().join("session"); if session_path.exists() { @@ -47,15 +47,16 @@ impl Cmd { let session = api_client::login( settings.sync_address.as_str(), LoginRequest { username, password }, - )?; + ) + .await?; let session_path = settings.session_path.as_str(); - let mut file = File::create(session_path)?; - file.write_all(session.session.as_bytes())?; + let mut file = File::create(session_path).await?; + file.write_all(session.session.as_bytes()).await?; let key_path = settings.key_path.as_str(); - let mut file = File::create(key_path)?; - file.write_all(key.as_bytes())?; + let mut file = File::create(key_path).await?; + file.write_all(key.as_bytes()).await?; println!("Logged in!"); |
