1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-22 17:18:37 +00:00

Add CLI import for wallabag v2 files

This commit is contained in:
Nicolas Lœuillet 2016-04-27 20:30:24 +02:00
parent 7b67f785ff
commit 3fad6c74fe
3 changed files with 66 additions and 47 deletions

View file

@ -13,10 +13,12 @@ class ImportCommand extends ContainerAwareCommand
protected function configure()
{
$this
->setName('wallabag:import-v1')
->setName('wallabag:import')
->setDescription('Import entries from a JSON export from a wallabag v1 instance')
->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate')
->addArgument('filepath', InputArgument::REQUIRED, 'Path to the JSON file')
->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: v1 or v2', 'v1')
->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read: true/false', false)
;
}
@ -35,6 +37,15 @@ class ImportCommand extends ContainerAwareCommand
}
$wallabag = $this->getContainer()->get('wallabag_import.wallabag_v1.import');
if ('v2' === $input->getOption('importer')) {
$wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import');
}
if ('yes' === $input->getOption('markAsRead')) {
$wallabag->setMarkAsRead(true);
}
$res = $wallabag
->setUser($user)
->setFilepath($input->getArgument('filepath'))