Skip to content

Commit 1f3f543

Browse files
committed
added confirmation to purge queue
1 parent 7e24413 commit 1f3f543

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Command/PurgeQueueCommand.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
6565
->setDescription(self::getDescription())
6666
->addArgument('queue-config', [
6767
'help' => __('Queue configuration key'),
68+
])
69+
->addOption('yes', [
70+
'short' => 'y',
71+
'boolean' => true,
72+
'default' => false,
73+
'help' => __('Yes - skip confirmation prompt')
6874
]);
6975
}
7076

@@ -91,10 +97,25 @@ public function execute(Arguments $args, ConsoleIo $io)
9197
} else {
9298
$io->error(__('There are no queue configurations'));
9399
}
100+
$this->displayHelp($this->getOptionParser(), $args, $io);
94101

95102
return self::CODE_ERROR;
96103
}
97104

105+
if (!$args->getOption('yes')) {
106+
$confirmation = $io->askChoice(
107+
__('Are you sure you want to purge messages from specified queue?'),
108+
[
109+
__('yes'),
110+
__('no')
111+
],
112+
__('no')
113+
);
114+
115+
if ($confirmation === __('no')) {
116+
$io->abort(__('Aborting'));
117+
}
118+
}
98119
try {
99120
$this->enqueueClientService->purgeQueue($queueConfig);
100121
$io->success(__('Queue purged successfully'));

0 commit comments

Comments
 (0)