mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 09:18:08 +02:00
show message even for password asks
This commit is contained in:
@@ -3,14 +3,23 @@
|
|||||||
package ask
|
package ask
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"kitty/tools/cli"
|
"kitty/tools/cli"
|
||||||
|
"kitty/tools/cli/markup"
|
||||||
"kitty/tools/tui"
|
"kitty/tools/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = fmt.Print
|
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) {
|
func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||||
output := tui.KittenOutputSerializer()
|
output := tui.KittenOutputSerializer()
|
||||||
var result any
|
var result any
|
||||||
@@ -21,13 +30,19 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
|||||||
case "yesno", "choices":
|
case "yesno", "choices":
|
||||||
result, err = choices(o, args)
|
result, err = choices(o, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return rc, err
|
return 1, err
|
||||||
}
|
}
|
||||||
case "password":
|
case "password":
|
||||||
result, err = tui.ReadPassword(o.Prompt, true)
|
show_message(o.Message)
|
||||||
|
pw, err := tui.ReadPassword(o.Prompt, true)
|
||||||
if err != nil {
|
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:
|
default:
|
||||||
return 1, fmt.Errorf("Unknown type: %s", o.Type)
|
return 1, fmt.Errorf("Unknown type: %s", o.Type)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user