diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-11-23 11:36:20 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-11-23 11:36:20 +0100 |
commit | 909b31ea58eb1a8edf80830f2d0e7d97c72a6307 (patch) | |
tree | 69af40283bb5e8d2d08cb75ec302e9d62444487e /apps/files_external/command/listcommand.php | |
parent | f5cdd27b22b85e9dfb80bf1b4a29d296f437a3f2 (diff) | |
download | nextcloud-server-909b31ea58eb1a8edf80830f2d0e7d97c72a6307.tar.gz nextcloud-server-909b31ea58eb1a8edf80830f2d0e7d97c72a6307.zip |
use common --output option
Diffstat (limited to 'apps/files_external/command/listcommand.php')
-rw-r--r-- | apps/files_external/command/listcommand.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/apps/files_external/command/listcommand.php b/apps/files_external/command/listcommand.php index d7a6558c8b4..1c0a2d476fb 100644 --- a/apps/files_external/command/listcommand.php +++ b/apps/files_external/command/listcommand.php @@ -21,11 +21,10 @@ namespace OCA\Files_External\Command; +use OC\Core\Command\Base; use OCA\Files_external\Lib\StorageConfig; use OCA\Files_external\Service\GlobalStoragesService; use OCA\Files_external\Service\UserStoragesService; -use OCP\Files\IRootFolder; -use OCP\IUserBackend; use OCP\IUserManager; use OCP\IUserSession; use Symfony\Component\Console\Command\Command; @@ -36,7 +35,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class ListCommand extends Command { +class ListCommand extends Base { /** * @var GlobalStoragesService */ @@ -73,8 +72,8 @@ class ListCommand extends Command { 'user_id', InputArgument::OPTIONAL, 'user id to list the personal mounts for, if no user is provided admin mounts will be listed' - ) - ->addOption('json', null, InputOption::VALUE_NONE, 'use json output instead of a human-readable array'); + ); + parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output) { @@ -109,7 +108,8 @@ class ListCommand extends Command { $headers[] = 'Applicable Groups'; } - if ($input->getOption('json')) { + $outputType = $input->getOption('output'); + if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { $keys = array_map(function ($header) { return strtolower(str_replace(' ', '_', $header)); }, $headers); @@ -130,7 +130,11 @@ class ListCommand extends Command { return array_combine($keys, $values); }, $mounts); - $output->writeln(json_encode(array_values($pairs), JSON_PRETTY_PRINT)); + if ($outputType === self::OUTPUT_FORMAT_JSON) { + $output->writeln(json_encode(array_values($pairs))); + } else { + $output->writeln(json_encode(array_values($pairs), JSON_PRETTY_PRINT)); + } } else { $defaultMountOptions = [ 'encrypt' => true, |