diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-04-27 20:30:24 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-05-27 09:43:48 +0200 |
commit | 3fad6c74fe72b50bceb5f1c67c3f81370660634e (patch) | |
tree | a99eec7d509da8df008d7977324827e59581ac52 /src | |
parent | 7b67f785ff09e093286f3fd665eb263807cbb760 (diff) | |
download | wallabag-3fad6c74fe72b50bceb5f1c67c3f81370660634e.tar.gz wallabag-3fad6c74fe72b50bceb5f1c67c3f81370660634e.tar.zst wallabag-3fad6c74fe72b50bceb5f1c67c3f81370660634e.zip |
Add CLI import for wallabag v2 files
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/ImportBundle/Command/ImportCommand.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php index dfbfc2f7..f62176fc 100644 --- a/src/Wallabag/ImportBundle/Command/ImportCommand.php +++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php | |||
@@ -13,10 +13,12 @@ class ImportCommand extends ContainerAwareCommand | |||
13 | protected function configure() | 13 | protected function configure() |
14 | { | 14 | { |
15 | $this | 15 | $this |
16 | ->setName('wallabag:import-v1') | 16 | ->setName('wallabag:import') |
17 | ->setDescription('Import entries from a JSON export from a wallabag v1 instance') | 17 | ->setDescription('Import entries from a JSON export from a wallabag v1 instance') |
18 | ->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate') | 18 | ->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate') |
19 | ->addArgument('filepath', InputArgument::REQUIRED, 'Path to the JSON file') | 19 | ->addArgument('filepath', InputArgument::REQUIRED, 'Path to the JSON file') |
20 | ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: v1 or v2', 'v1') | ||
21 | ->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read: true/false', false) | ||
20 | ; | 22 | ; |
21 | } | 23 | } |
22 | 24 | ||
@@ -35,6 +37,15 @@ class ImportCommand extends ContainerAwareCommand | |||
35 | } | 37 | } |
36 | 38 | ||
37 | $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v1.import'); | 39 | $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v1.import'); |
40 | |||
41 | if ('v2' === $input->getOption('importer')) { | ||
42 | $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); | ||
43 | } | ||
44 | |||
45 | if ('yes' === $input->getOption('markAsRead')) { | ||
46 | $wallabag->setMarkAsRead(true); | ||
47 | } | ||
48 | |||
38 | $res = $wallabag | 49 | $res = $wallabag |
39 | ->setUser($user) | 50 | ->setUser($user) |
40 | ->setFilepath($input->getArgument('filepath')) | 51 | ->setFilepath($input->getArgument('filepath')) |