Commit ff79221 1 parent e8feb1b commit ff79221 Copy full SHA for ff79221
File tree 1 file changed +9
-8
lines changed
qlty-cli/src/commands/auth
1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
- use std:: io:: stdin;
2
-
3
1
use crate :: { Arguments , CommandError , CommandSuccess } ;
4
- use anyhow:: Result ;
2
+ use anyhow:: { Context , Result } ;
5
3
use clap:: Args ;
6
4
use console:: style;
5
+ use dialoguer:: Input ;
7
6
use qlty_cloud:: { load_or_retrieve_auth_token, store_auth_token} ;
8
7
9
8
#[ derive( Args , Debug ) ]
@@ -17,15 +16,17 @@ impl Login {
17
16
pub fn execute ( & self , _args : & Arguments ) -> Result < CommandSuccess , CommandError > {
18
17
if let Some ( mut token) = self . token . clone ( ) {
19
18
if token == "" || token == "-" {
20
- eprint ! (
21
- "Generate a token from {} and paste it here.\n Token: " ,
19
+ eprintln ! (
20
+ "Generate a token from {} and paste it here." ,
22
21
style( "https://qlty.sh/user/settings/cli" )
23
22
. underlined( )
24
23
. green( )
25
24
) ;
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" ) ?;
29
30
}
30
31
31
32
if !token. starts_with ( "qltyp_" ) || token. len ( ) < 32 {
You can’t perform that action at this time.
0 commit comments