diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-18 10:37:47 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-18 10:37:47 +0200 |
commit | 1e458f186d878d51b64c8d843e356808d41bc84d (patch) | |
tree | afd09f93f1970b6f14f11c9cfb1804452eee5c5f | |
parent | bcfa18c0c6c70a4f6fd37f242101d25b5fc099f0 (diff) | |
parent | 0a36331cb614770b5d004ca193126fce650bcd55 (diff) | |
download | nextcloud-server-1e458f186d878d51b64c8d843e356808d41bc84d.tar.gz nextcloud-server-1e458f186d878d51b64c8d843e356808d41bc84d.zip |
Merge pull request #17686 from owncloud/fix-occ-config-commands
Fix occ config commands
-rw-r--r-- | core/command/app/listapps.php | 2 | ||||
-rw-r--r-- | core/command/base.php | 16 | ||||
-rw-r--r-- | core/command/config/app/deleteconfig.php | 4 | ||||
-rw-r--r-- | core/command/config/app/setconfig.php | 2 | ||||
-rw-r--r-- | core/command/config/listconfigs.php | 7 | ||||
-rw-r--r-- | core/command/config/system/deleteconfig.php | 2 | ||||
-rw-r--r-- | core/command/config/system/setconfig.php | 2 | ||||
-rw-r--r-- | core/command/encryption/listmodules.php | 2 |
8 files changed, 20 insertions, 17 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 7e61c0cb9ab..0a4b002c1ca 100644 --- a/core/command/base.php +++ b/core/command/base.php @@ -27,6 +27,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Base extends Command { + 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 ->addOption( @@ -34,7 +40,7 @@ class Base extends Command { null, InputOption::VALUE_OPTIONAL, 'Output format (plain, json or json_pretty, default is plain)', - 'plain' + $this->defaultOutputFormat ) ; } @@ -47,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: @@ -87,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/app/deleteconfig.php b/core/command/config/app/deleteconfig.php index 0031142358e..bc031b0d589 100644 --- a/core/command/config/app/deleteconfig.php +++ b/core/command/config/app/deleteconfig.php @@ -70,12 +70,12 @@ class DeleteConfig extends Base { $configName = $input->getArgument('name'); if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->config->getAppKeys($appName))) { - $output->writeln('<error>Config ' . $configName . ' could not be deleted because it did not exist</error>'); + $output->writeln('<error>Config ' . $configName . ' of app ' . $appName . ' could not be deleted because it did not exist</error>'); return 1; } $this->config->deleteAppValue($appName, $configName); - $output->writeln('<info>System config value ' . $configName . ' deleted</info>'); + $output->writeln('<info>Config value ' . $configName . ' of app ' . $appName . ' deleted</info>'); return 0; } } diff --git a/core/command/config/app/setconfig.php b/core/command/config/app/setconfig.php index 91775094fdd..eea58a63c5e 100644 --- a/core/command/config/app/setconfig.php +++ b/core/command/config/app/setconfig.php @@ -76,7 +76,7 @@ class SetConfig extends Base { $configName = $input->getArgument('name'); if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { - $output->writeln('<comment>Value not updated, as it has not been set before.</comment>'); + $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); return 1; } diff --git a/core/command/config/listconfigs.php b/core/command/config/listconfigs.php index be3073e54d9..fed6a8e9db6 100644 --- a/core/command/config/listconfigs.php +++ b/core/command/config/listconfigs.php @@ -30,6 +30,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListConfigs extends Base { + protected $defaultOutputFormat = self::OUTPUT_FORMAT_JSON_PRETTY; + /** @var array */ protected $sensitiveValues = [ 'dbpassword', @@ -81,11 +83,6 @@ class ListConfigs extends Base { $app = $input->getArgument('app'); $noSensitiveValues = !$input->getOption('private'); - if ($noSensitiveValues && !$input->hasParameterOption('--output')) { - // If you post this publicly we prefer the json format - $input->setOption('output', 'json_pretty'); - } - switch ($app) { case 'system': $configs = [ diff --git a/core/command/config/system/deleteconfig.php b/core/command/config/system/deleteconfig.php index 49bc2bc8c03..4d193647c85 100644 --- a/core/command/config/system/deleteconfig.php +++ b/core/command/config/system/deleteconfig.php @@ -64,7 +64,7 @@ class DeleteConfig extends Base { $configName = $input->getArgument('name'); if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) { - $output->writeln('<error>Config ' . $configName . ' could not be deleted because it did not exist</error>'); + $output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>'); return 1; } diff --git a/core/command/config/system/setconfig.php b/core/command/config/system/setconfig.php index cb2f9fe616f..82b36cca164 100644 --- a/core/command/config/system/setconfig.php +++ b/core/command/config/system/setconfig.php @@ -70,7 +70,7 @@ class SetConfig extends Base { $configName = $input->getArgument('name'); if (!in_array($configName, $this->systemConfig->getKeys()) && $input->hasParameterOption('--update-only')) { - $output->writeln('<comment>Value not updated, as it has not been set before.</comment>'); + $output->writeln('<comment>Config value ' . $configName . ' not updated, as it has not been set before.</comment>'); return 1; } $configValue = $input->getOption('value'); 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']; |