Skip to content

Commit

Permalink
fix: reset prompt state upon exiting watch mode (issue DiceDB#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpsinghg committed Nov 22, 2024
1 parent e7d9383 commit c984a58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func Run(host string, port int) {
Fn: func(buf *prompt.Buffer) {
if dicedbClient.subscribed {
fmt.Println("Exiting watch mode.")
dicedbClient.subCancel()

dicedbClient.handleWatchModeExit()
} else {
handleExit()
}
Expand Down Expand Up @@ -173,6 +174,12 @@ func (c *DiceDBClient) handleWatchCommand(cmd string, args []string) {
go c.watchCommand(baseCmd, toArgInterface(args[1:])...)
}

func (c *DiceDBClient) handleWatchModeExit() {
c.subCancel()
c.subscribed = false
c.subType = ""
}

func (c *DiceDBClient) handleUnsubscribe() {
if !c.subscribed || c.subType != CmdSubscribe {
fmt.Println("Not subscribed to any channels.")
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ echo "\n
╚═════╝ ╚═╝ ╚═════╝╚══════╝╚═════╝ ╚═════╝
"
echo "> if you get 'command not found' error, add '/usr/local/bin' to your 'PATH' variable."
echo "\nDiceDB CLI installation complete ✓"
echo "DiceDB CLI installation complete ✓"

0 comments on commit c984a58

Please sign in to comment.