aboutsummaryrefslogtreecommitdiff
path: root/cli/import-sqlite-for-user.php
diff options
context:
space:
mode:
Diffstat (limited to 'cli/import-sqlite-for-user.php')
-rwxr-xr-xcli/import-sqlite-for-user.php25
1 files changed, 16 insertions, 9 deletions
diff --git a/cli/import-sqlite-for-user.php b/cli/import-sqlite-for-user.php
index b61a73523..29b7c1b0c 100755
--- a/cli/import-sqlite-for-user.php
+++ b/cli/import-sqlite-for-user.php
@@ -5,20 +5,27 @@ require(__DIR__ . '/_cli.php');
performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
-$params = [
- 'user:',
- 'filename:',
- 'force-overwrite',
+$parameters = [
+ 'long' => [
+ 'user' => ':',
+ 'filename' => ':',
+ 'force-overwrite' => '',
+ ],
+ 'short' => [],
+ 'deprecated' => [],
];
-$options = getopt('', $params);
+$options = parseCliParams($parameters);
-if (!validateOptions($argv, $params) || empty($options['user']) || empty($options['filename']) || !is_string($options['user']) || !is_string($options['filename'])) {
+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 --force-overwrite --filename /path/to/db.sqlite');
}
-$username = cliInitUser($options['user']);
-$filename = $options['filename'];
+$username = cliInitUser($options['valid']['user']);
+$filename = $options['valid']['filename'];
if (pathinfo($filename, PATHINFO_EXTENSION) !== 'sqlite') {
fail('Only *.sqlite files are supported!');
@@ -27,7 +34,7 @@ if (pathinfo($filename, PATHINFO_EXTENSION) !== 'sqlite') {
echo 'FreshRSS importing database from SQLite for user “', $username, "”…\n";
$databaseDAO = FreshRSS_Factory::createDatabaseDAO($username);
-$clearFirst = array_key_exists('force-overwrite', $options);
+$clearFirst = array_key_exists('force-overwrite', $options['valid']);
$ok = $databaseDAO->dbCopy($filename, FreshRSS_DatabaseDAO::SQLITE_IMPORT, $clearFirst);
if (!$ok) {
echo 'If you would like to clear the user database first, use the option --force-overwrite', "\n";