Skip to content

Commit

Permalink
Add a selfoss CLI tool
Browse files Browse the repository at this point in the history
This introduces two commands for dumping and loading the database contents:

- `php bin/selfoss db:export path.json`
- `php bin/selfoss db:import path.json`

Those are useful for testing, as well as for moving data from one database backend to another.
  • Loading branch information
jtojnar committed Nov 4, 2021
1 parent 1ccb803 commit f0f41a8
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 154 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
->exclude('assets')
->exclude('utils')
->in(__DIR__)
->name('*.phtml');
->name('*.phtml')
->name('selfoss');

$rules = [
'@Symfony' => true,
Expand Down
20 changes: 20 additions & 0 deletions bin/selfoss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php

require __DIR__ . '/../src/common.php';

use Commands\Database\ExportCommand as DatabaseExportCommand;
use Commands\Database\ImportCommand as DatabaseImportCommand;
use Monolog\Handler\StreamHandler;
use Symfony\Component\Console\Application;

$application = new Application();

$log->popHandler();
$handler = new StreamHandler('php://stderr');
$log->pushHandler($handler);

$application->add($dice->create(DatabaseExportCommand::class));
$application->add($dice->create(DatabaseImportCommand::class));

$application->run();
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"php-http/guzzle6-adapter": "^1.0",
"simplepie/simplepie": "^1.3",
"smottt/wideimage": "^1.1",
"symfony/console": "^3.4",
"violet/streaming-json-encoder": "^1.1",
"willwashburn/phpamo": "^1.0"
},
Expand All @@ -39,6 +40,7 @@
],
"autoload": {
"psr-4": {
"Commands\\": "src/Commands/",
"controllers\\": "src/controllers/",
"daos\\": "src/daos/",
"helpers\\": "src/helpers/",
Expand Down
306 changes: 153 additions & 153 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f0f41a8

Please sign in to comment.