Implement reading of password

This commit is contained in:
Kovid Goyal
2023-03-07 13:10:12 +05:30
parent bb22990af9
commit 0da998ac53

View File

@@ -14,12 +14,20 @@ var _ = fmt.Print
func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
output := tui.KittenOutputSerializer()
var result any
if len(o.Prompt) > 2 && o.Prompt[0] == o.Prompt[len(o.Prompt)-1] && (o.Prompt[0] == '"' || o.Prompt[0] == '\'') {
o.Prompt = o.Prompt[1 : len(o.Prompt)-1]
}
switch o.Type {
case "yesno", "choices":
result, err = choices(o, args)
if err != nil {
return rc, err
}
case "password":
result, err = tui.ReadPassword(o.Prompt, true)
if err != nil {
return rc, err
}
default:
return 1, fmt.Errorf("Unknown type: %s", o.Type)
}