feat: exit on EOF (^D/ctrl d)

pull/5/head
TorchedSammy 2021-03-20 12:57:18 -04:00
parent 7ac391e3b1
commit 4456d7593b
1 changed files with 5 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"syscall" "syscall"
"os/signal" "os/signal"
"strings" "strings"
"io"
"github.com/akamensky/argparse" "github.com/akamensky/argparse"
"github.com/bobappleyard/readline" "github.com/bobappleyard/readline"
@ -51,6 +52,10 @@ func main() {
//fmt.Printf(prompt) //fmt.Printf(prompt)
cmdString, err := readline.String(prompt) cmdString, err := readline.String(prompt)
if err == io.EOF {
fmt.Println("")
break
}
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
} }