This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree 1 file changed +9
-9
lines changed
1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 4
4
"bufio"
5
5
"context"
6
6
"fmt"
7
- "io"
8
7
"net/url"
9
8
"strings"
10
9
@@ -73,7 +72,15 @@ func login(cmd *cobra.Command, envURL *url.URL) error {
73
72
fmt .Printf ("Your browser has been opened to visit:\n \n \t %s\n \n " , authURL .String ())
74
73
}
75
74
76
- token := readLine ("Paste token here: " , cmd .InOrStdin ())
75
+ fmt .Print ("Paste token here: " )
76
+ var token string
77
+ scanner := bufio .NewScanner (cmd .InOrStdin ())
78
+ _ = scanner .Scan ()
79
+ token = scanner .Text ()
80
+ if err := scanner .Err (); err != nil {
81
+ return xerrors .Errorf ("reading standard input: %w" , err )
82
+ }
83
+
77
84
if err := pingAPI (cmd .Context (), envURL , token ); err != nil {
78
85
return xerrors .Errorf ("ping API with credentials: %w" , err )
79
86
}
@@ -84,13 +91,6 @@ func login(cmd *cobra.Command, envURL *url.URL) error {
84
91
return nil
85
92
}
86
93
87
- func readLine (prompt string , r io.Reader ) string {
88
- reader := bufio .NewReader (r )
89
- fmt .Print (prompt )
90
- text , _ := reader .ReadString ('\n' )
91
- return strings .TrimSuffix (text , "\n " )
92
- }
93
-
94
94
// pingAPI creates a client from the given url/token and try to exec an api call.
95
95
// Not using the SDK as we want to verify the url/token pair before storing the config files.
96
96
func pingAPI (ctx context.Context , envURL * url.URL , token string ) error {
You can’t perform that action at this time.
0 commit comments