aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-05-04 11:53:44 +0200
committerThomas Citharel <tcit@tcit.fr>2017-05-04 14:41:42 +0200
commitd1e5059ea0ccfbf8e224e71f8d233b01ddfbc92d (patch)
tree40d6010f355341bc47ba2f577b0aea6758263edc /src/Wallabag
parent3b4502e0e663866e7bac00164fd935fdc92309d6 (diff)
downloadwallabag-d1e5059ea0ccfbf8e224e71f8d233b01ddfbc92d.tar.gz
wallabag-d1e5059ea0ccfbf8e224e71f8d233b01ddfbc92d.tar.zst
wallabag-d1e5059ea0ccfbf8e224e71f8d233b01ddfbc92d.zip
Use username to import
Signed-off-by: Thomas Citharel <tcit@tcit.fr> add docs Signed-off-by: Thomas Citharel <tcit@tcit.fr> use username as default Signed-off-by: Thomas Citharel <tcit@tcit.fr> rename user to username typo Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/ImportBundle/Command/ImportCommand.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php
index 28d01715..ce72837a 100644
--- a/src/Wallabag/ImportBundle/Command/ImportCommand.php
+++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php
@@ -15,10 +15,11 @@ class ImportCommand extends ContainerAwareCommand
15 $this 15 $this
16 ->setName('wallabag:import') 16 ->setName('wallabag:import')
17 ->setDescription('Import entries from a JSON export') 17 ->setDescription('Import entries from a JSON export')
18 ->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate') 18 ->addArgument('username', InputArgument::REQUIRED, 'User 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, v2, instapaper, pinboard, readability, firefox or chrome', 'v1') 20 ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: v1, v2, instapaper, pinboard, 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 ->addOption('useUserId', null, InputArgument::OPTIONAL, 'Use user id instead of username to find account', false)
22 ; 23 ;
23 } 24 }
24 25
@@ -34,10 +35,14 @@ class ImportCommand extends ContainerAwareCommand
34 // Turning off doctrine default logs queries for saving memory 35 // Turning off doctrine default logs queries for saving memory
35 $em->getConnection()->getConfiguration()->setSQLLogger(null); 36 $em->getConnection()->getConfiguration()->setSQLLogger(null);
36 37
37 $user = $em->getRepository('WallabagUserBundle:User')->findOneById($input->getArgument('userId')); 38 if ($input->getOption('useUserId')) {
39 $user = $em->getRepository('WallabagUserBundle:User')->findOneById($input->getArgument('username'));
40 } else {
41 $user = $em->getRepository('WallabagUserBundle:User')->findOneByUsername($input->getArgument('username'));
42 }
38 43
39 if (!is_object($user)) { 44 if (!is_object($user)) {
40 throw new Exception(sprintf('User with id "%s" not found', $input->getArgument('userId'))); 45 throw new Exception(sprintf('User "%s" not found', $input->getArgument('username')));
41 } 46 }
42 47
43 switch ($input->getOption('importer')) { 48 switch ($input->getOption('importer')) {