Skip to content

Commit ff79221

Browse files
committed
1 parent e8feb1b commit ff79221

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

qlty-cli/src/commands/auth/login.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use std::io::stdin;
2-
31
use crate::{Arguments, CommandError, CommandSuccess};
4-
use anyhow::Result;
2+
use anyhow::{Context, Result};
53
use clap::Args;
64
use console::style;
5+
use dialoguer::Input;
76
use qlty_cloud::{load_or_retrieve_auth_token, store_auth_token};
87

98
#[derive(Args, Debug)]
@@ -17,15 +16,17 @@ impl Login {
1716
pub fn execute(&self, _args: &Arguments) -> Result<CommandSuccess, CommandError> {
1817
if let Some(mut token) = self.token.clone() {
1918
if token == "" || token == "-" {
20-
eprint!(
21-
"Generate a token from {} and paste it here.\nToken: ",
19+
eprintln!(
20+
"Generate a token from {} and paste it here.",
2221
style("https://qlty.sh/user/settings/cli")
2322
.underlined()
2423
.green()
2524
);
26-
let line = &mut String::new();
27-
stdin().read_line(line)?;
28-
token = line.trim().to_string();
25+
token = Input::<String>::new()
26+
.with_prompt("Token")
27+
.interact_text()
28+
.map(|line| line.trim().to_string())
29+
.with_context(|| "Invalid input")?;
2930
}
3031

3132
if !token.starts_with("qltyp_") || token.len() < 32 {

0 commit comments

Comments
 (0)