diff options
| author | 2025-03-22 23:17:52 +0100 | |
|---|---|---|
| committer | 2025-03-22 23:17:52 +0100 | |
| commit | 64bbb42553c925ebf7177945d048c18675188584 (patch) | |
| tree | e9f11e54b44512628304bcd83a1f6f418529099f /cli/user-info.php | |
| parent | 72ad6e528cc7d65d4d4f401a705cd9e2e6183c1a (diff) | |
Fix CLI flag parsing (#7430)
* Fix CLI flag parsing
fix https://github.com/FreshRSS/FreshRSS/issues/7428
* Fix other places
* Forgotten debugging
Diffstat (limited to 'cli/user-info.php')
| -rwxr-xr-x | cli/user-info.php | 21 |
1 files changed, 10 insertions, 11 deletions
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<int,string> $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"; } |
