Skip to content

Commit

Permalink
Merge pull request #62 from emead-indeed/emead-indeed-password-stdin
Browse files Browse the repository at this point in the history
Add support to reading password from stdin
  • Loading branch information
kovetskiy authored Feb 2, 2021
2 parents 9bd12bc + 7c68fec commit ffd5728
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package main

import (
"errors"
"io/ioutil"
"net/url"
"os"
"strings"

"github.com/reconquest/karma-go"
Expand Down Expand Up @@ -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)
if err != nil {
return nil, karma.Format(
Expand Down

0 comments on commit ffd5728

Please sign in to comment.