summaryrefslogtreecommitdiffstats
path: root/core/command
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-07-17 09:25:19 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-07-17 09:25:19 +0200
commit0a36331cb614770b5d004ca193126fce650bcd55 (patch)
tree5db94c82f5fdb160f0789c6d2bba77df91ec332c /core/command
parent01dc3935d03cb08703b47bfeef50dcbb7f5458e7 (diff)
downloadnextcloud-server-0a36331cb614770b5d004ca193126fce650bcd55.tar.gz
nextcloud-server-0a36331cb614770b5d004ca193126fce650bcd55.zip
Use constants for the output formats
Diffstat (limited to 'core/command')
-rw-r--r--core/command/app/listapps.php2
-rw-r--r--core/command/base.php14
-rw-r--r--core/command/config/listconfigs.php2
-rw-r--r--core/command/encryption/listmodules.php2
4 files changed, 12 insertions, 8 deletions
diff --git a/core/command/app/listapps.php b/core/command/app/listapps.php
index e30baddb745..e483037d45d 100644
--- a/core/command/app/listapps.php
+++ b/core/command/app/listapps.php
@@ -73,7 +73,7 @@ class ListApps extends Base {
*/
protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
switch ($input->getOption('output')) {
- case 'plain':
+ case self::OUTPUT_FORMAT_PLAIN:
$output->writeln('Enabled:');
parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
diff --git a/core/command/base.php b/core/command/base.php
index 7936e683dcc..0a4b002c1ca 100644
--- a/core/command/base.php
+++ b/core/command/base.php
@@ -27,7 +27,11 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Base extends Command {
- protected $defaultOutputFormat = 'plain';
+ const OUTPUT_FORMAT_PLAIN = 'plain';
+ const OUTPUT_FORMAT_JSON = 'json';
+ const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty';
+
+ protected $defaultOutputFormat = self::OUTPUT_FORMAT_PLAIN;
protected function configure() {
$this
@@ -49,10 +53,10 @@ class Base extends Command {
*/
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = ' - ') {
switch ($input->getOption('output')) {
- case 'json':
+ case self::OUTPUT_FORMAT_JSON:
$output->writeln(json_encode($items));
break;
- case 'json_pretty':
+ case self::OUTPUT_FORMAT_JSON_PRETTY:
$output->writeln(json_encode($items, JSON_PRETTY_PRINT));
break;
default:
@@ -89,10 +93,10 @@ class Base extends Command {
}
switch ($input->getOption('output')) {
- case 'json':
+ case self::OUTPUT_FORMAT_JSON:
$output->writeln(json_encode($item));
break;
- case 'json_pretty':
+ case self::OUTPUT_FORMAT_JSON_PRETTY:
$output->writeln(json_encode($item, JSON_PRETTY_PRINT));
break;
default:
diff --git a/core/command/config/listconfigs.php b/core/command/config/listconfigs.php
index d80bd2b98ca..fed6a8e9db6 100644
--- a/core/command/config/listconfigs.php
+++ b/core/command/config/listconfigs.php
@@ -30,7 +30,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ListConfigs extends Base {
- protected $defaultOutputFormat = 'json_pretty';
+ protected $defaultOutputFormat = self::OUTPUT_FORMAT_JSON_PRETTY;
/** @var array */
protected $sensitiveValues = [
diff --git a/core/command/encryption/listmodules.php b/core/command/encryption/listmodules.php
index d55480def87..cc436ea5629 100644
--- a/core/command/encryption/listmodules.php
+++ b/core/command/encryption/listmodules.php
@@ -65,7 +65,7 @@ class ListModules extends Base {
* @param array $items
*/
protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) {
- if ($input->getOption('output') === 'plain') {
+ if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
array_walk($items, function(&$item) {
if (!$item['default']) {
$item = $item['displayName'];