fix: listen for device flow completion without requiring enter

This commit is contained in:
daimond113 2024-10-17 22:07:55 +02:00
parent 051e062c39
commit 14aeabeed2
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 16 additions and 12 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Use updated aliases when reusing lockfile dependencies by @daimond113
- Listen for device flow completion without requiring pressing enter by @daimond113
## [0.5.0-rc.6] - 2024-10-14
### Added

View file

@ -2,6 +2,7 @@ use anyhow::Context;
use clap::Args;
use colored::Colorize;
use serde::Deserialize;
use std::thread::spawn;
use url::Url;
use pesde::{
@ -81,19 +82,21 @@ impl LoginCommand {
response.verification_uri.as_str().blue()
);
{
let mut input = String::new();
std::io::stdin()
.read_line(&mut input)
.context("failed to read input")?;
}
match open::that(response.verification_uri.as_str()) {
Ok(_) => (),
Err(e) => {
eprintln!("failed to open browser: {e}");
spawn(move || {
{
let mut input = String::new();
std::io::stdin()
.read_line(&mut input)
.expect("failed to read input");
}
}
match open::that(response.verification_uri.as_str()) {
Ok(_) => (),
Err(e) => {
eprintln!("failed to open browser: {e}");
}
}
});
let mut time_left = response.expires_in;
let mut interval = std::time::Duration::from_secs(response.interval);