|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | +/** |
| 4 | + * @copyright Copyright (c) 2022 Solution Libre SAS |
| 5 | + * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl> |
| 6 | + * |
| 7 | + * @author Florent Poinsaut <florent@solution-libre.fr> |
| 8 | + * @author Roeland Jago Douma <roeland@famdouma.nl> |
| 9 | + * @author John Molakvoæ <skjnldsv@protonmail.com> |
| 10 | + * |
| 11 | + * @license GNU AGPL version 3 or any later version |
| 12 | + * |
| 13 | + * This program is free software: you can redistribute it and/or modify |
| 14 | + * it under the terms of the GNU Affero General Public License as |
| 15 | + * published by the Free Software Foundation, either version 3 of the |
| 16 | + * License, or (at your option) any later version. |
| 17 | + * |
| 18 | + * This program is distributed in the hope that it will be useful, |
| 19 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | + * GNU Affero General Public License for more details. |
| 22 | + * |
| 23 | + * You should have received a copy of the GNU Affero General Public License |
| 24 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 | + * |
| 26 | + */ |
| 27 | + |
| 28 | +namespace OCA\ShareListing\Command; |
| 29 | + |
| 30 | +use OCA\ShareListing\Service\SharesList; |
| 31 | +use OC\Core\Command\Base; |
| 32 | +use Symfony\Component\Console\Input\InputInterface; |
| 33 | +use Symfony\Component\Console\Input\InputOption; |
| 34 | + |
| 35 | +abstract class AbstractCommand extends Base { |
| 36 | + /** @var SharesList */ |
| 37 | + protected $sharesList; |
| 38 | + |
| 39 | + public function __construct(SharesList $sharesList) { |
| 40 | + parent::__construct(); |
| 41 | + |
| 42 | + $this->sharesList = $sharesList; |
| 43 | + } |
| 44 | + |
| 45 | + public function configure() { |
| 46 | + $this->addOption( |
| 47 | + 'user', |
| 48 | + 'u', |
| 49 | + InputOption::VALUE_OPTIONAL, |
| 50 | + 'Will list shares of the given user' |
| 51 | + ) |
| 52 | + ->addOption( |
| 53 | + 'path', |
| 54 | + 'p', |
| 55 | + InputOption::VALUE_OPTIONAL, |
| 56 | + 'Will only consider the given path' |
| 57 | + )->addOption( |
| 58 | + 'token', |
| 59 | + 't', |
| 60 | + InputOption::VALUE_OPTIONAL, |
| 61 | + 'Will only consider the given token' |
| 62 | + )->addOption( |
| 63 | + 'filter', |
| 64 | + 'f', |
| 65 | + InputOption::VALUE_OPTIONAL, |
| 66 | + 'Filter shares, possible values: owner, initiator, recipient, token, has-expiration, no-expiration' |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | + protected function getOptions(InputInterface $input): array { |
| 71 | + $user = $input->getOption('user'); |
| 72 | + $path = $input->getOption('path'); |
| 73 | + $token = $input->getOption('token'); |
| 74 | + $filter = $this->sharesList->filterStringToInt($input->getOption('filter')); |
| 75 | + |
| 76 | + return [$user, $path, $token, $filter]; |
| 77 | + } |
| 78 | +} |
0 commit comments