mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Allow using defer in KittenMain
This commit is contained in:
@@ -565,13 +565,6 @@ func (self *Command) ExecArgs(args []string) (exit_code int) {
|
||||
return
|
||||
}
|
||||
|
||||
func (self *Command) Exec(args ...string) {
|
||||
if len(args) == 0 {
|
||||
args = os.Args
|
||||
}
|
||||
os.Exit(self.ExecArgs(args))
|
||||
}
|
||||
|
||||
func (self *Command) GetCompletions(argv []string, init_completions func(*Completions)) *Completions {
|
||||
ans := NewCompletions()
|
||||
if init_completions != nil {
|
||||
|
||||
@@ -16,13 +16,12 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func KittenMain(args ...string) {
|
||||
func KittenMain(args ...string) int {
|
||||
krm := os.Getenv("KITTY_KITTEN_RUN_MODULE")
|
||||
os.Unsetenv("KITTY_KITTEN_RUN_MODULE")
|
||||
switch krm {
|
||||
case "ssh_askpass":
|
||||
ssh.RunSSHAskpass()
|
||||
return
|
||||
return ssh.RunSSHAskpass()
|
||||
}
|
||||
root := cli.NewRootCommand()
|
||||
root.ShortDescription = "Fast, statically compiled implementations of various kittens (command line tools for use with kitty)"
|
||||
@@ -49,9 +48,9 @@ func KittenMain(args ...string) {
|
||||
completion.EntryPoint(root)
|
||||
|
||||
root.SubCommandIsOptional = true
|
||||
root.Exec(args...)
|
||||
return root.ExecArgs(args)
|
||||
}
|
||||
|
||||
func main() {
|
||||
KittenMain()
|
||||
os.Exit(KittenMain())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user