@@ -4,13 +4,14 @@ import (
44 "context"
55 "errors"
66 "fmt"
7- "github.com/redis/go-redis/v9"
8- "github.com/wailsapp/wails/v2/pkg/runtime"
97 "strings"
108 "sync"
119 "tinyrdm/backend/types"
1210 sliceutil "tinyrdm/backend/utils/slice"
1311 strutil "tinyrdm/backend/utils/string"
12+
13+ "github.com/redis/go-redis/v9"
14+ "github.com/wailsapp/wails/v2/pkg/runtime"
1415)
1516
1617type cliService struct {
@@ -22,8 +23,9 @@ type cliService struct {
2223}
2324
2425type cliOutput struct {
25- Content []string `json:"content"` // output content
26- Prompt string `json:"prompt,omitempty"` // new line prompt, empty if not ready to input
26+ Null bool `json:"null,omitempty"` // output content is null
27+ Content []string `json:"content,omitempty"` // output content
28+ Prompt string `json:"prompt,omitempty"` // new line prompt, empty if not ready to input
2729}
2830
2931var cli * cliService
@@ -55,7 +57,7 @@ func (c *cliService) runCommand(server, data string) {
5557 }
5658 }
5759
58- c .echo (server , strutil . AnyToString ( result , "" , 0 ) , true )
60+ c .echo (server , result , true )
5961 } else {
6062 c .echoError (server , err .Error ())
6163 }
@@ -66,9 +68,11 @@ func (c *cliService) runCommand(server, data string) {
6668 c .echoReady (server )
6769}
6870
69- func (c * cliService ) echo (server , data string , newLineReady bool ) {
70- output := cliOutput {
71- Content : strings .Split (data , "\n " ),
71+ func (c * cliService ) echo (server string , data any , newLineReady bool ) {
72+ var output cliOutput
73+ if data != nil {
74+ str := strutil .AnyToString (data , "" , 0 )
75+ output .Content = strings .Split (str , "\n " )
7276 }
7377 if newLineReady {
7478 output .Prompt = fmt .Sprintf ("%s:db%d> " , server , c .selectedDB [server ])
0 commit comments