mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 13:33:32 +02:00
Allow reading password from stdin
Allow reading password from stdin in `jira login`. This is useful for combining the jira tool with other command-line utilities.
This commit is contained in:
@@ -3,6 +3,7 @@ package jiracli
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
@@ -57,6 +58,12 @@ func (o *GlobalOptions) GetPass() string {
|
||||
passwd = strings.TrimSpace(buf.String())
|
||||
}
|
||||
}
|
||||
} else if o.PasswordSource.Value == "stdin" {
|
||||
allBytes, err := ioutil.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("unable to read bytes from stdin: %s", err))
|
||||
}
|
||||
passwd = string(allBytes)
|
||||
} else {
|
||||
log.Warningf("Unknown password-source: %s", o.PasswordSource)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user