diff --git a/src/API/System/Parity.php b/src/API/System/Parity.php
index 981cc7df..52c9602f 100644
--- a/src/API/System/Parity.php
+++ b/src/API/System/Parity.php
@@ -67,7 +67,7 @@ final class Parity
$total = (int)$stmt->fetchColumn();
$lastPage = @ceil($total / $perpage);
- if ($page > $lastPage) {
+ if ($total && $page > $lastPage) {
return api_error(r("Invalid page number. '{page}' is higher than what the last page is '{last_page}'.", [
'page' => $page,
'last_page' => $lastPage,
diff --git a/src/Commands/Config/DeleteCommand.php b/src/Commands/Config/DeleteCommand.php
index 2df40b3f..6f64cc93 100644
--- a/src/Commands/Config/DeleteCommand.php
+++ b/src/Commands/Config/DeleteCommand.php
@@ -50,7 +50,7 @@ final class DeleteCommand extends Command
This command allows you to delete local backend data from the database.
- This command require interaction to work. to bypass the check use --no-interaction flag.
+ This command require interaction to work. to bypass the check use [-n, --no-interaction] flag.
This command will do the following:
diff --git a/src/Commands/Database/ListCommand.php b/src/Commands/Database/ListCommand.php
index c5187af4..45427da0 100644
--- a/src/Commands/Database/ListCommand.php
+++ b/src/Commands/Database/ListCommand.php
@@ -204,6 +204,8 @@ final class ListCommand extends Command
{cmd} {route} --parent tvdb://269586 --mark-as played
+ This flag require interaction to work. to bypass the check use [-n, --no-interaction] flag.
+
HELP,
[
'cmd' => trim(commandContext()),
diff --git a/src/Commands/Database/ParityCommand.php b/src/Commands/Database/ParityCommand.php
index 450050c9..ba5a2ff6 100644
--- a/src/Commands/Database/ParityCommand.php
+++ b/src/Commands/Database/ParityCommand.php
@@ -13,6 +13,7 @@ use App\Libs\HTTP_STATUS;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* Class ParityCommand
@@ -76,6 +77,7 @@ final class ParityCommand extends Command
{cmd} {route} --min 3 --prune
Warning, this command will delete the entire match, not limited by --limit flag.
+ This flag require interaction to work. to bypass the check use [-n, --no-interaction] flag.
HELP,
[
@@ -127,6 +129,51 @@ final class ParityCommand extends Command
}
if (true === $prune) {
+ if (!$input->getOption('no-interaction')) {
+ $paging = ag($response->body, 'paging', []);
+ $tty = !(function_exists('stream_isatty') && defined('STDERR')) || stream_isatty(STDERR);
+ if (false === $tty || $input->getOption('no-interaction')) {
+ $output->writeln(
+ r(
+ <<ERROR: This command require interaction. For example:
+ {cmd} {route} --prune
+ ERROR,
+ [
+ 'cmd' => trim(commandContext()),
+ 'route' => self::ROUTE,
+ ]
+ )
+ );
+ return self::FAILURE;
+ }
+
+ $helper = $this->getHelper('question');
+
+ $question = new ConfirmationQuestion(
+ r(
+ <<Are you sure you want to delete [{count}] records from database? {default}
+ ------------------
+ NOTICE: You would have to re-import the records using [state:import] command.
+ ------------------
+ For more information please read the FAQ.
+ HELP. PHP_EOL . '> ',
+ [
+ 'count' => ag($paging, 'total', 0),
+ 'cmd' => trim(commandContext()),
+ 'default' => '[Y|N] [Default: No]',
+ ]
+ ),
+ false,
+ );
+
+ if (true !== $helper->ask($input, $output, $question)) {
+ $output->writeln('Pruning aborted.');
+ return self::SUCCESS;
+ }
+ }
+
$response = APIRequest('DELETE', '/system/parity/', opts: ['query' => ['min' => $min]]);
if (HTTP_STATUS::HTTP_OK !== $response->status) {
diff --git a/src/Commands/System/LogsCommand.php b/src/Commands/System/LogsCommand.php
index 9d17983d..fffd1668 100644
--- a/src/Commands/System/LogsCommand.php
+++ b/src/Commands/System/LogsCommand.php
@@ -103,10 +103,11 @@ final class LogsCommand extends Command
# How to clear log file?
- You can clear log file by running this command, However clearing log file require interactive confirmation.
-
{cmd} {route} --type {defaultLog} --date {defaultDate} --clear
+ You can clear log file by running this command, However clearing log file require interaction.
+ To bypass the check use [-n, --no-interaction] flag.
+
# How to increase/decrease the returned log lines?
By default, we return the last [{defaultLimit}] log lines. However, you can increase/decrease