1010use ReflectionException ;
1111use yii \base \Action ;
1212use yii \console \Controller ;
13+ use yii \console \ExitCode ;
1314use yii \helpers \Console ;
1415
1516/**
@@ -101,7 +102,7 @@ public function actionConsume(string $name): int
101102 {
102103 $ this ->stderr (Console::ansiFormat ("Consumer ` {$ name }` doesn't exist: {$ e ->getMessage ()}\n" , [Console::FG_RED ]));
103104
104- return self :: EXIT_CODE_ERROR ;
105+ return ExitCode:: UNSPECIFIED_ERROR ;
105106 }
106107
107108 $ this ->validateConsumerOptions ($ consumer );
@@ -111,7 +112,7 @@ public function actionConsume(string $name): int
111112 }
112113 $ consumer ->consume ($ this ->messagesLimit );
113114
114- return self :: EXIT_CODE_NORMAL ;
115+ return ExitCode:: OK ;
115116 }
116117
117118 /**
@@ -136,15 +137,15 @@ public function actionPublish(string $producerName, string $exchangeName, string
136137 {
137138 $ this ->stderr (Console::ansiFormat ("Producer ` {$ producerName }` doesn't exist: {$ e ->getMessage ()}\n" , [Console::FG_RED ]));
138139
139- return self :: EXIT_CODE_ERROR ;
140+ return ExitCode:: UNSPECIFIED_ERROR ;
140141 }
141142
142143 $ data = '' ;
143144 if (posix_isatty (STDIN ))
144145 {
145146 $ this ->stderr (Console::ansiFormat ("Please pipe in some data in order to send it. \n" , [Console::FG_RED ]));
146147
147- return self :: EXIT_CODE_ERROR ;
148+ return ExitCode:: UNSPECIFIED_ERROR ;
148149 }
149150 while (!feof (STDIN ))
150151 {
@@ -153,7 +154,7 @@ public function actionPublish(string $producerName, string $exchangeName, string
153154 $ producer ->publish ($ data , $ exchangeName , $ routingKey );
154155 $ this ->stdout ("Message was successfully published. \n" , Console::FG_GREEN );
155156
156- return self :: EXIT_CODE_NORMAL ;
157+ return ExitCode:: OK ;
157158 }
158159
159160 /**
@@ -175,11 +176,11 @@ public function actionDeclareAll(string $connectionName = Configuration::DEFAULT
175176 Console::ansiFormat ("All configured entries was successfully declared. \n" , [Console::FG_GREEN ])
176177 );
177178
178- return self :: EXIT_CODE_NORMAL ;
179+ return ExitCode:: OK ;
179180 }
180181 $ this ->stderr (Console::ansiFormat ("No queues, exchanges or bindings configured. \n" , [Console::FG_RED ]));
181182
182- return self :: EXIT_CODE_ERROR ;
183+ return ExitCode:: UNSPECIFIED_ERROR ;
183184 }
184185
185186 /**
@@ -201,12 +202,12 @@ public function actionDeclareExchange(
201202 {
202203 $ this ->stderr (Console::ansiFormat ("Exchange ` {$ exchangeName }` is already exists. \n" , [Console::FG_RED ]));
203204
204- return self :: EXIT_CODE_ERROR ;
205+ return ExitCode:: UNSPECIFIED_ERROR ;
205206 }
206207 $ routing ->declareExchange ($ exchangeName );
207208 $ this ->stdout (Console::ansiFormat ("Exchange ` {$ exchangeName }` was declared. \n" , [Console::FG_GREEN ]));
208209
209- return self :: EXIT_CODE_NORMAL ;
210+ return ExitCode:: OK ;
210211 }
211212
212213 /**
@@ -228,12 +229,12 @@ public function actionDeclareQueue(
228229 {
229230 $ this ->stderr (Console::ansiFormat ("Queue ` {$ queueName }` is already exists. \n" , [Console::FG_RED ]));
230231
231- return self :: EXIT_CODE_ERROR ;
232+ return ExitCode:: UNSPECIFIED_ERROR ;
232233 }
233234 $ routing ->declareQueue ($ queueName );
234235 $ this ->stdout (Console::ansiFormat ("Queue ` {$ queueName }` was declared. \n" , [Console::FG_GREEN ]));
235236
236- return self :: EXIT_CODE_NORMAL ;
237+ return ExitCode:: OK ;
237238 }
238239
239240 /**
@@ -249,19 +250,19 @@ public function actionDeleteAll(string $connection = Configuration::DEFAULT_CONN
249250 if ($ this ->interactive )
250251 {
251252 $ input = Console::prompt ('Are you sure you want to delete all queues and exchanges? ' , ['default ' => 'yes ' ]);
252- if ($ input !== 'yes ' )
253+ if ($ input !== 'yes ' && $ input !== ' y ' )
253254 {
254255 $ this ->stderr (Console::ansiFormat ("Aborted. \n" , [Console::FG_RED ]));
255256
256- return self :: EXIT_CODE_ERROR ;
257+ return ExitCode:: UNSPECIFIED_ERROR ;
257258 }
258259 }
259260 $ conn = \Yii::$ app ->rabbitmq ->getConnection ($ connection );
260261 $ routing = \Yii::$ app ->rabbitmq ->getRouting ($ conn );
261262 $ routing ->deleteAll ();
262263 $ this ->stdout (Console::ansiFormat ("All configured entries was deleted. \n" , [Console::FG_GREEN ]));
263264
264- return self :: EXIT_CODE_NORMAL ;
265+ return ExitCode:: OK ;
265266 }
266267
267268 /**
@@ -284,15 +285,15 @@ public function actionDeleteExchange(
284285 {
285286 $ this ->stderr (Console::ansiFormat ("Aborted. \n" , [Console::FG_RED ]));
286287
287- return self :: EXIT_CODE_ERROR ;
288+ return ExitCode:: UNSPECIFIED_ERROR ;
288289 }
289290 }
290291 $ conn = \Yii::$ app ->rabbitmq ->getConnection ($ connectionName );
291292 $ routing = \Yii::$ app ->rabbitmq ->getRouting ($ conn );
292293 $ routing ->deleteExchange ($ exchangeName );
293294 $ this ->stdout (Console::ansiFormat ("Exchange ` {$ exchangeName }` was deleted. \n" , [Console::FG_GREEN ]));
294295
295- return self :: EXIT_CODE_NORMAL ;
296+ return ExitCode:: OK ;
296297 }
297298
298299 /**
@@ -315,7 +316,7 @@ public function actionDeleteQueue(
315316 {
316317 $ this ->stderr (Console::ansiFormat ("Aborted. \n" , [Console::FG_RED ]));
317318
318- return self :: EXIT_CODE_ERROR ;
319+ return ExitCode:: UNSPECIFIED_ERROR ;
319320 }
320321 }
321322
@@ -324,7 +325,7 @@ public function actionDeleteQueue(
324325 $ routing ->deleteQueue ($ queueName );
325326 $ this ->stdout (Console::ansiFormat ("Queue ` {$ queueName }` was deleted. \n" , [Console::FG_GREEN ]));
326327
327- return self :: EXIT_CODE_NORMAL ;
328+ return ExitCode:: OK ;
328329 }
329330
330331 /**
@@ -350,7 +351,7 @@ public function actionPurgeQueue(
350351 {
351352 $ this ->stderr (Console::ansiFormat ("Aborted. \n" , [Console::FG_RED ]));
352353
353- return self :: EXIT_CODE_ERROR ;
354+ return ExitCode:: UNSPECIFIED_ERROR ;
354355 }
355356 }
356357
@@ -359,7 +360,7 @@ public function actionPurgeQueue(
359360 $ routing ->purgeQueue ($ queueName );
360361 $ this ->stdout (Console::ansiFormat ("Queue ` {$ queueName }` was purged. \n" , [Console::FG_GREEN ]));
361362
362- return self :: EXIT_CODE_NORMAL ;
363+ return ExitCode:: OK ;
363364 }
364365
365366 /**
0 commit comments