Skip to content

Commit

Permalink
fix memory & extra log & prompt prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora233 committed Jan 10, 2021
1 parent 797d985 commit 2b54c6f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion cli/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func BuntdbExecutor(s string) {
}
tx, rw := db.GetCurrentTransaction()
if ctx.Selected().Name == "use" {
fmt.Printf("tx %v", tx)
err = ctx.Run(tx)
if err != nil {
fmt.Printf("ERR: %v\n", err)
Expand Down
3 changes: 3 additions & 0 deletions cli/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func (u *UseGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error {
if tx != nil {
return db.ErrTransactionExist
}
if u.Path == ":memory:" {
return db.InitBuntDB(u.Path)
}
f, err := os.Lstat(u.Path)
if err != nil {
if !os.IsNotExist(err) {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func main() {
prompt.OptionLivePrefix(func() (prefix string, useLivePrefix bool) {
tx, rw := db.GetCurrentTransaction()
if tx != nil {
return path.Base(CLI.Path) + fmt.Sprintf("(%v)", db.RWDescribe(rw)) + "> ", true
return path.Base(db.GetDbPath()) + fmt.Sprintf("(%v)", db.RWDescribe(rw)) + "> ", true
} else {
return path.Base(CLI.Path) + "> ", true
return path.Base(db.GetDbPath()) + "> ", true
}
}),
prompt.OptionSetExitCheckerOnInput(func(in string, breakline bool) bool {
Expand Down

0 comments on commit 2b54c6f

Please sign in to comment.