From 64bbb42553c925ebf7177945d048c18675188584 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 22 Mar 2025 23:17:52 +0100 Subject: Fix CLI flag parsing (#7430) * Fix CLI flag parsing fix https://github.com/FreshRSS/FreshRSS/issues/7428 * Fix other places * Forgotten debugging --- cli/user-info.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'cli/user-info.php') diff --git a/cli/user-info.php b/cli/user-info.php index 5895d9b1d..04de8c68d 100755 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -8,9 +8,9 @@ const DATA_FORMAT = "%-7s | %-20s | %-5s | %-7s | %-25s | %-15s | %-10s | %-10s $cliOptions = new class extends CliOptionsParser { /** @var array $user */ public array $user; - public string $header; - public string $json; - public string $humanReadable; + public bool $header; + public bool $json; + public bool $humanReadable; public function __construct() { $this->addOption('user', (new CliOption('user'))->typeOfArrayOfString()); @@ -29,14 +29,13 @@ $users = $cliOptions->user ?? listUsers(); sort($users); -$formatJson = isset($cliOptions->json); $jsonOutput = []; -if ($formatJson) { - unset($cliOptions->header); - unset($cliOptions->humanReadable); +if ($cliOptions->json) { + $cliOptions->header = false; + $cliOptions->humanReadable = false; } -if (isset($cliOptions->header)) { +if ($cliOptions->header) { printf( DATA_FORMAT, 'default', @@ -85,12 +84,12 @@ foreach ($users as $username) { 'lang' => FreshRSS_Context::userConf()->language, 'mail_login' => FreshRSS_Context::userConf()->mail_login, ]; - if (isset($cliOptions->humanReadable)) { //Human format + if ($cliOptions->humanReadable) { //Human format $data['last_user_activity'] = date('c', $data['last_user_activity']); $data['database_size'] = format_bytes($data['database_size']); } - if ($formatJson) { + if ($cliOptions->json) { $data['default'] = !empty($data['default']); $data['admin'] = !empty($data['admin']); $data['enabled'] = !empty($data['enabled']); @@ -101,7 +100,7 @@ foreach ($users as $username) { } } -if ($formatJson) { +if ($cliOptions->json) { echo json_encode($jsonOutput), "\n"; } -- cgit v1.2.3