Refactor error-handling for line input
This commit is contained in:
parent
419356b5cd
commit
b84e6d6bd0
13
gelim.go
13
gelim.go
|
@ -152,17 +152,18 @@ func main() {
|
||||||
color.Unset()
|
color.Unset()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != ln.ErrPromptAborted && err != io.EOF {
|
if err == ln.ErrPromptAborted || err == io.EOF {
|
||||||
c.style.ErrorMsg("error reading line input: " + err.Error())
|
// Exit by ^C or ^D
|
||||||
}
|
|
||||||
fmt.Println()
|
|
||||||
if err == io.EOF {
|
|
||||||
// Exit by CTRL-D.
|
|
||||||
c.QuitClient(0)
|
c.QuitClient(0)
|
||||||
|
if err == io.EOF {
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
c.style.ErrorMsg("Error reading input: " + err.Error())
|
||||||
// Exiting because it will cause an infinite loop of error if used 'continue' here
|
// Exiting because it will cause an infinite loop of error if used 'continue' here
|
||||||
c.QuitClient(1)
|
c.QuitClient(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.AppendHistory(line)
|
rl.AppendHistory(line)
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
if line == "" {
|
if line == "" {
|
||||||
|
|
Loading…
Reference in New Issue