Add support to reading password from stdin

This commit is contained in:
emead-indeed 2021-01-27 10:58:44 +09:00 committed by GitHub
parent 9bd12bc2e5
commit 7c68fec718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
auth.go
View File

@ -2,7 +2,9 @@ package main
import ( import (
"errors" "errors"
"io/ioutil"
"net/url" "net/url"
"os"
"strings" "strings"
"github.com/reconquest/karma-go" "github.com/reconquest/karma-go"
@ -47,6 +49,17 @@ func GetCredentials(
} }
} }
if password == "-" {
b, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return nil, karma.Format(
err,
"unable to read password from stdin",
)
}
password = string(b)
}
url, err := url.Parse(targetURL) url, err := url.Parse(targetURL)
if err != nil { if err != nil {
return nil, karma.Format( return nil, karma.Format(