Merge pull request #62 from emead-indeed/emead-indeed-password-stdin

Add support to reading password from stdin
This commit is contained in:
Egor Kovetskiy 2021-02-02 07:53:42 +03:00 committed by GitHub
commit ffd572899a
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(