2021-04-11 22:59:08 -04:00
|
|
|
// +build !windows,!darwin,!js
|
2021-04-08 20:26:57 -04:00
|
|
|
|
|
|
|
package zenity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/ncruces/zenity/internal/zenutil"
|
|
|
|
)
|
|
|
|
|
2021-04-29 11:05:28 -04:00
|
|
|
func password(opts options) (string, string, error) {
|
2021-04-08 20:26:57 -04:00
|
|
|
args := []string{"--password"}
|
|
|
|
args = appendTitle(args, opts)
|
|
|
|
args = appendButtons(args, opts)
|
|
|
|
if opts.username {
|
|
|
|
args = append(args, "--username")
|
|
|
|
}
|
|
|
|
|
|
|
|
out, err := zenutil.Run(opts.ctx, args)
|
2021-04-29 11:05:28 -04:00
|
|
|
str, err := strResult(opts, out, err)
|
|
|
|
if err == nil && opts.username {
|
2021-04-08 20:26:57 -04:00
|
|
|
if split := strings.SplitN(string(out), "|", 2); len(split) == 2 {
|
2021-04-29 11:05:28 -04:00
|
|
|
return split[0], split[1], nil
|
2021-04-08 20:26:57 -04:00
|
|
|
}
|
|
|
|
}
|
2021-04-29 11:05:28 -04:00
|
|
|
return "", str, err
|
2021-04-08 20:26:57 -04:00
|
|
|
}
|