Skip to content

Commit 2433758

Browse files
committed
show err when db invalid & update exit
1 parent e1d28ee commit 2433758

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

main.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/c-bata/go-prompt"
99
"os"
1010
"path"
11+
"strings"
1112
)
1213

1314
var CLI struct {
@@ -18,7 +19,6 @@ var CLI struct {
1819

1920
func main() {
2021
kong.Parse(&CLI, kong.UsageOnError(), kong.Name("buntdb-cli"))
21-
defer os.Exit(0)
2222

2323
if CLI.Debug {
2424
cli.Debug = true
@@ -28,7 +28,11 @@ func main() {
2828
CLI.Path = db.GetTempDbPath("buntdb-cli")
2929
}
3030

31-
db.InitBuntDB(CLI.Path)
31+
err := db.InitBuntDB(CLI.Path)
32+
if err != nil {
33+
fmt.Printf("ERR: %v\n", err)
34+
os.Exit(1)
35+
}
3236
defer db.Close()
3337

3438
p := prompt.New(
@@ -44,7 +48,7 @@ func main() {
4448
}
4549
}),
4650
prompt.OptionSetExitCheckerOnInput(func(in string, breakline bool) bool {
47-
return in == "exit" && breakline
51+
return strings.TrimSpace(in) == "exit" && breakline
4852
}),
4953
)
5054
p.Run()

0 commit comments

Comments
 (0)