mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-01-04 12:14:21 +00:00
Permit usernames with spaces. (#178)
+ We have an account with a space in it; the tool should accomodate this. + Additionally, support supplying only the username to the program.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
@@ -76,13 +77,33 @@ func registerFlags() {
|
||||
flag.DurationVar(&pollInterval, "poll-interval", time.Second, "interval for polling an outstanding order (set 0 to disable polling)")
|
||||
}
|
||||
|
||||
func readLine(prompt string) (line string, err error) {
|
||||
fmt.Printf(prompt)
|
||||
rd := bufio.NewReader(os.Stdin)
|
||||
line, err = rd.ReadString('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
line = strings.TrimSpace(line)
|
||||
return
|
||||
}
|
||||
|
||||
func getUserCredentials() {
|
||||
user = os.Getenv(userEnv)
|
||||
pswd = os.Getenv(pswdEnv)
|
||||
if user == "" || pswd == "" {
|
||||
fmt.Print("Username:")
|
||||
fmt.Scan(&user)
|
||||
var err error
|
||||
var err error
|
||||
if user == "" {
|
||||
user = os.Getenv(userEnv)
|
||||
}
|
||||
|
||||
if pswd == "" {
|
||||
pswd = os.Getenv(pswdEnv)
|
||||
}
|
||||
|
||||
if user == "" {
|
||||
user, err = readLine("Username: ")
|
||||
processError(err)
|
||||
}
|
||||
|
||||
if pswd == "" {
|
||||
pswd, err = gopass.GetPass("Password:")
|
||||
processError(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user