mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-24 13:17:59 -05:00
* Separates long & short options for parsing * Adds parsing for short options + doc rewrites * Fixes undefined constant in check.translation * Standardises CL option parsing * Refactors option parsing * Renames getLongOptions -> getOptions * Removes unused code * Converges on string typing for options * Updates docs & help files * Updates array syntax array( ) -> [ ]
39 lines
1.0 KiB
PHP
Executable File
39 lines
1.0 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
declare(strict_types=1);
|
|
require(__DIR__ . '/_cli.php');
|
|
|
|
performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
|
|
|
|
$parameters = [
|
|
'long' => [
|
|
'user' => ':',
|
|
'filename' => ':',
|
|
],
|
|
'short' => [],
|
|
'deprecated' => [],
|
|
];
|
|
|
|
$options = parseCliParams($parameters);
|
|
|
|
if (!empty($options['invalid'])
|
|
|| empty($options['valid']['user']) || empty($options['valid']['filename'])
|
|
|| !is_string($options['valid']['user']) || !is_string($options['valid']['filename'])
|
|
) {
|
|
fail('Usage: ' . basename(__FILE__) . ' --user username --filename /path/to/db.sqlite');
|
|
}
|
|
|
|
$username = cliInitUser($options['valid']['user']);
|
|
$filename = $options['valid']['filename'];
|
|
|
|
if (pathinfo($filename, PATHINFO_EXTENSION) !== 'sqlite') {
|
|
fail('Only *.sqlite files are supported!');
|
|
}
|
|
|
|
echo 'FreshRSS exporting database to SQLite for user “', $username, "”…\n";
|
|
|
|
$databaseDAO = FreshRSS_Factory::createDatabaseDAO($username);
|
|
$ok = $databaseDAO->dbCopy($filename, FreshRSS_DatabaseDAO::SQLITE_EXPORT);
|
|
|
|
done($ok);
|