show message even for password asks
This commit is contained in:
parent
f4b0fbc61e
commit
4cef83ffd0
@ -3,14 +3,23 @@
|
||||
package ask
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"kitty/tools/cli"
|
||||
"kitty/tools/cli/markup"
|
||||
"kitty/tools/tui"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func show_message(msg string) {
|
||||
if msg != "" {
|
||||
m := markup.New(true)
|
||||
fmt.Println(m.Bold(msg))
|
||||
}
|
||||
}
|
||||
|
||||
func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
output := tui.KittenOutputSerializer()
|
||||
var result any
|
||||
@ -21,13 +30,19 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
case "yesno", "choices":
|
||||
result, err = choices(o, args)
|
||||
if err != nil {
|
||||
return rc, err
|
||||
return 1, err
|
||||
}
|
||||
case "password":
|
||||
result, err = tui.ReadPassword(o.Prompt, true)
|
||||
show_message(o.Message)
|
||||
pw, err := tui.ReadPassword(o.Prompt, true)
|
||||
if err != nil {
|
||||
return rc, err
|
||||
if errors.Is(err, tui.Canceled) {
|
||||
pw = ""
|
||||
} else {
|
||||
return 1, err
|
||||
}
|
||||
}
|
||||
result = map[string]any{"items": args, "response": pw}
|
||||
default:
|
||||
return 1, fmt.Errorf("Unknown type: %s", o.Type)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user