Skip to content

Commit

Permalink
Add \q to exit, fix exit/quit not working sometimes, small optimizati…
Browse files Browse the repository at this point in the history
…on (eatonphil#7)

* Add \q to exit, fix oversight, small optimization

* Remove useless comment

* ignores only trailing whitespace

* Revert some changes
  • Loading branch information
krischerven authored Apr 14, 2020
1 parent 4e93078 commit da63063
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"strings"

"github.com/eatonphil/gosql"

Expand Down Expand Up @@ -99,9 +100,12 @@ repl:
fmt.Println("Error while reading line:", err)
continue repl
}
if line == "quit" || line == "exit" {

trimmedLine := strings.TrimRight(line, " ")
if trimmedLine == "quit" || trimmedLine == "exit" || strings.TrimLeft(trimmedLine, " ") == "\\q" {
break
}

ast, err := gosql.Parse(line)
if err != nil {
fmt.Println("Error while parsing:", err)
Expand Down

0 comments on commit da63063

Please sign in to comment.