Skip to content

Commit

Permalink
added confirmation to purge queue
Browse files Browse the repository at this point in the history
  • Loading branch information
arusinowski committed Nov 18, 2024
1 parent 7e24413 commit 1f3f543
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Command/PurgeQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
->setDescription(self::getDescription())
->addArgument('queue-config', [
'help' => __('Queue configuration key'),
])
->addOption('yes', [
'short' => 'y',
'boolean' => true,
'default' => false,
'help' => __('Yes - skip confirmation prompt')
]);
}

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

return self::CODE_ERROR;
}

if (!$args->getOption('yes')) {
$confirmation = $io->askChoice(
__('Are you sure you want to purge messages from specified queue?'),
[
__('yes'),
__('no')
],
__('no')
);

if ($confirmation === __('no')) {
$io->abort(__('Aborting'));
}
}
try {
$this->enqueueClientService->purgeQueue($queueConfig);
$io->success(__('Queue purged successfully'));
Expand Down

0 comments on commit 1f3f543

Please sign in to comment.