[ease-of-use] Display "Enter Password" on STDERR

This enables users to sequence `passbolt` commands ahead of common processors... such as:

```
passbolt list resource | fzf
passbolt get resource -j abc-123-321-cba | jq ".Password"
```

As is, displaying the prompt on STDIN means the prompt (and occasionally user response) is gobbled up by the second command in the sequence. STDERR is a common out-of-band backup for interactive prompts in many similar cases.

I am inexperienced in Golang, and am unsure how solid this is; simply queried the ideal API call.
This commit is contained in:
Calliope 2025-02-25 15:51:44 -05:00 committed by GitHub
parent 1183813dcb
commit 1109927984
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,7 +22,7 @@ func ReadPassword(prompt string) (string, error) {
fd := int(os.Stdin.Fd()) fd := int(os.Stdin.Fd())
var pass string var pass string
if term.IsTerminal(fd) { if term.IsTerminal(fd) {
fmt.Print(prompt) fmt.Fprint(os.Stderr, prompt);
inputPass, err := term.ReadPassword(fd) inputPass, err := term.ReadPassword(fd)
if err != nil { if err != nil {