diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-02 07:10:57 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-02 07:10:57 +0100 |
commit | 1f66d79e6b5f54375e63799f10d0773203fe12f9 (patch) | |
tree | 53820434e85e680f2b6316711ab1cd01708c7771 /src | |
parent | 7816eb622df2353cea0ede0a3674d5eb3a01a1a9 (diff) | |
download | wallabag-1f66d79e6b5f54375e63799f10d0773203fe12f9.tar.gz wallabag-1f66d79e6b5f54375e63799f10d0773203fe12f9.tar.zst wallabag-1f66d79e6b5f54375e63799f10d0773203fe12f9.zip |
Add more importer to wallabag:import command
All importer available expect Pocket which require an oAuth login.
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/ImportBundle/Command/ImportCommand.php | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php index 1df38295..2f7a906e 100644 --- a/src/Wallabag/ImportBundle/Command/ImportCommand.php +++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php | |||
@@ -14,10 +14,10 @@ class ImportCommand extends ContainerAwareCommand | |||
14 | { | 14 | { |
15 | $this | 15 | $this |
16 | ->setName('wallabag:import') | 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') |
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: wallabag v1, v2, firefox or chrome', 'v1') | 20 | ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: v1, v2, instapaper, readability, firefox or chrome', 'v1') |
21 | ->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read', false) | 21 | ->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read', false) |
22 | ; | 22 | ; |
23 | } | 23 | } |
@@ -42,29 +42,35 @@ class ImportCommand extends ContainerAwareCommand | |||
42 | 42 | ||
43 | switch ($input->getOption('importer')) { | 43 | switch ($input->getOption('importer')) { |
44 | case 'v2': | 44 | case 'v2': |
45 | $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); | 45 | $import = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); |
46 | break; | 46 | break; |
47 | case 'firefox': | 47 | case 'firefox': |
48 | $wallabag = $this->getContainer()->get('wallabag_import.firefox.import'); | 48 | $import = $this->getContainer()->get('wallabag_import.firefox.import'); |
49 | break; | 49 | break; |
50 | case 'chrome': | 50 | case 'chrome': |
51 | $wallabag = $this->getContainer()->get('wallabag_import.chrome.import'); | 51 | $import = $this->getContainer()->get('wallabag_import.chrome.import'); |
52 | break; | ||
53 | case 'readability': | ||
54 | $import = $this->getContainer()->get('wallabag_import.readability.import'); | ||
55 | break; | ||
56 | case 'instapaper': | ||
57 | $import = $this->getContainer()->get('wallabag_import.instapaper.import'); | ||
52 | break; | 58 | break; |
53 | case 'v1': | 59 | case 'v1': |
54 | default: | 60 | default: |
55 | $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v1.import'); | 61 | $import = $this->getContainer()->get('wallabag_import.wallabag_v1.import'); |
56 | break; | 62 | break; |
57 | } | 63 | } |
58 | 64 | ||
59 | $wallabag->setMarkAsRead($input->getOption('markAsRead')); | 65 | $import->setMarkAsRead($input->getOption('markAsRead')); |
60 | $wallabag->setUser($user); | 66 | $import->setUser($user); |
61 | 67 | ||
62 | $res = $wallabag | 68 | $res = $import |
63 | ->setFilepath($input->getArgument('filepath')) | 69 | ->setFilepath($input->getArgument('filepath')) |
64 | ->import(); | 70 | ->import(); |
65 | 71 | ||
66 | if (true === $res) { | 72 | if (true === $res) { |
67 | $summary = $wallabag->getSummary(); | 73 | $summary = $import->getSummary(); |
68 | $output->writeln('<info>'.$summary['imported'].' imported</info>'); | 74 | $output->writeln('<info>'.$summary['imported'].' imported</info>'); |
69 | $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>'); | 75 | $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>'); |
70 | } | 76 | } |