summaryrefslogtreecommitdiffstats
path: root/lib/Command
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-09-29 13:54:17 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-29 14:56:07 +0200
commit35b53ecd404a74edea3c6866e451c4819bdc9ea8 (patch)
treedac46834d8fa7ec0122243f94604c3d2215b4d22 /lib/Command
parentd6d169be15913404f99b86c39a03bc71942c9f77 (diff)
OPML export command and fixes
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Command')
-rw-r--r--lib/Command/Config/OpmlExport.php50
-rw-r--r--lib/Command/ShowFeed.php11
2 files changed, 61 insertions, 0 deletions
diff --git a/lib/Command/Config/OpmlExport.php b/lib/Command/Config/OpmlExport.php
new file mode 100644
index 000000000..1642e8505
--- /dev/null
+++ b/lib/Command/Config/OpmlExport.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace OCA\News\Command\Config;
+
+use OCA\News\Service\OpmlService;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class OpmlExport extends Command
+{
+ /**
+ * @var OpmlService service for the data.
+ */
+ protected $opmlService;
+
+ public function __construct(OpmlService $opmlService)
+ {
+ parent::__construct(null);
+
+ $this->opmlService = $opmlService;
+ }
+
+ /**
+ * Configure command
+ */
+ protected function configure()
+ {
+ $this->setName('news:opml:export')
+ ->setDescription('Print OPML file')
+ ->addArgument('userID', InputArgument::REQUIRED, 'User data to export');
+ }
+
+ /**
+ * Execute command
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ *
+ * @return int|void
+ */
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $user = $input->getArgument('userID');
+
+ $output->write($this->opmlService->export($user));
+ return 0;
+ }
+}
diff --git a/lib/Command/ShowFeed.php b/lib/Command/ShowFeed.php
index 1218279e6..8aace3528 100644
--- a/lib/Command/ShowFeed.php
+++ b/lib/Command/ShowFeed.php
@@ -50,6 +50,9 @@ class ShowFeed extends Command
$this->feedFetcher = $feedFetcher;
}
+ /**
+ * Configure the command
+ */
protected function configure()
{
$this->setName('news:show-feed')
@@ -60,6 +63,14 @@ class ShowFeed extends Command
->addOption('full-text', 'f', InputOption::VALUE_NONE, 'Usa a scraper to get full text');
}
+ /**
+ * Execute the command
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ *
+ * @return int
+ */
protected function execute(InputInterface $input, OutputInterface $output): int
{
$url = $input->getArgument('feed');