Start work on porting the ask kitten

This commit is contained in:
Kovid Goyal
2023-03-07 08:50:12 +05:30
parent 672ecde68b
commit 0aa55fb755
5 changed files with 485 additions and 1 deletions

39
tools/cmd/ask/main.go Normal file
View File

@@ -0,0 +1,39 @@
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
package ask
import (
"fmt"
"kitty/tools/cli"
"kitty/tools/tui"
)
var _ = fmt.Print
func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
output := tui.KittenOutputSerializer()
var result any
switch o.Type {
case "yesno", "choices":
result, err = choices(o, args)
if err != nil {
return rc, err
}
default:
return 1, fmt.Errorf("Unknown type: %s", o.Type)
}
s, err := output(result)
if err != nil {
return 1, err
}
_, err = fmt.Println(s)
if err != nil {
return 1, err
}
return
}
func EntryPoint(parent *cli.Command) {
create_cmd(parent, main)
}