Skip to content

Commit ffd5728

Browse files
authored
Merge pull request #62 from emead-indeed/emead-indeed-password-stdin
Add support to reading password from stdin
2 parents 9bd12bc + 7c68fec commit ffd5728

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

auth.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package main
22

33
import (
44
"errors"
5+
"io/ioutil"
56
"net/url"
7+
"os"
68
"strings"
79

810
"github.com/reconquest/karma-go"
@@ -47,6 +49,17 @@ func GetCredentials(
4749
}
4850
}
4951

52+
if password == "-" {
53+
b, err := ioutil.ReadAll(os.Stdin)
54+
if err != nil {
55+
return nil, karma.Format(
56+
err,
57+
"unable to read password from stdin",
58+
)
59+
}
60+
password = string(b)
61+
}
62+
5063
url, err := url.Parse(targetURL)
5164
if err != nil {
5265
return nil, karma.Format(

0 commit comments

Comments
 (0)