summaryrefslogtreecommitdiffstats
path: root/lib/Command/Config/OpmlExport.php
blob: eec93ddbf1213f16dc728a3770cc388c7c731e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?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
     *
     * @return void
     */
    protected function configure()
    {
        $this->setName('news:opml:export')
            ->setDescription('Print OPML file')
            ->addArgument('user-id', InputArgument::REQUIRED, 'User data to export');
    }

    /**
     * Execute command
     *
     * @param InputInterface  $input
     * @param OutputInterface $output
     *
     * @return int
     */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $user = $input->getArgument('user-id');

        $output->write($this->opmlService->export($user));
        return 0;
    }
}