@@ -6,7 +6,12 @@ import {
6
6
ClusterNodeRole , ClusterSingleNodeOptions ,
7
7
CommandExecutionStatus ,
8
8
} from 'src/modules/cli/dto/cli.dto' ;
9
- import { checkRedirectionError , parseRedirectionError , splitCliCommandLine } from 'src/utils/cli-helper' ;
9
+ import {
10
+ checkHumanReadableCommands ,
11
+ checkRedirectionError ,
12
+ parseRedirectionError ,
13
+ splitCliCommandLine ,
14
+ } from 'src/utils/cli-helper' ;
10
15
import {
11
16
CommandNotSupportedError ,
12
17
CommandParsingError ,
@@ -63,8 +68,10 @@ export class WorkbenchCommandsExecutor {
63
68
64
69
try {
65
70
const [ command , ...args ] = splitCliCommandLine ( commandLine ) ;
71
+ const replyEncoding = checkHumanReadableCommands ( `${ command } ${ args [ 0 ] } ` ) ? 'utf8' : undefined ;
72
+
66
73
const response = this . formatter . format (
67
- await this . redisTool . execCommand ( clientOptions , command , args ) ,
74
+ await this . redisTool . execCommand ( clientOptions , command , args , replyEncoding ) ,
68
75
) ;
69
76
70
77
this . logger . log ( 'Succeed to execute workbench command.' ) ;
@@ -98,6 +105,7 @@ export class WorkbenchCommandsExecutor {
98
105
this . logger . log ( `Executing redis.cluster CLI command for single node ${ JSON . stringify ( nodeOptions ) } ` ) ;
99
106
try {
100
107
const [ command , ...args ] = splitCliCommandLine ( commandLine ) ;
108
+ const replyEncoding = checkHumanReadableCommands ( `${ command } ${ args [ 0 ] } ` ) ? 'utf8' : undefined ;
101
109
102
110
const nodeAddress = `${ nodeOptions . host } :${ nodeOptions . port } ` ;
103
111
let result = await this . redisTool . execCommandForNode (
@@ -106,6 +114,7 @@ export class WorkbenchCommandsExecutor {
106
114
args ,
107
115
role ,
108
116
nodeAddress ,
117
+ replyEncoding ,
109
118
) ;
110
119
if ( result . error && checkRedirectionError ( result . error ) && nodeOptions . enableRedirection ) {
111
120
const { slot, address } = parseRedirectionError ( result . error ) ;
@@ -115,6 +124,7 @@ export class WorkbenchCommandsExecutor {
115
124
args ,
116
125
role ,
117
126
address ,
127
+ replyEncoding ,
118
128
) ;
119
129
result . slot = parseInt ( slot , 10 ) ;
120
130
}
@@ -155,9 +165,10 @@ export class WorkbenchCommandsExecutor {
155
165
this . logger . log ( `Executing redis.cluster CLI command for [${ role } ] nodes.` ) ;
156
166
try {
157
167
const [ command , ...args ] = splitCliCommandLine ( commandLine ) ;
168
+ const replyEncoding = checkHumanReadableCommands ( `${ command } ${ args [ 0 ] } ` ) ? 'utf8' : undefined ;
158
169
159
170
return (
160
- await this . redisTool . execCommandForNodes ( clientOptions , command , args , role )
171
+ await this . redisTool . execCommandForNodes ( clientOptions , command , args , role , replyEncoding )
161
172
) . map ( ( nodeExecReply ) => {
162
173
const {
163
174
response, status, host, port,
0 commit comments