|
|
@@ -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";
|
|
|
}
|
|
|
|