Merge pull request #17686 from owncloud/fix-occ-config-commands

Fix occ config commands
This commit is contained in:
Morris Jobke 2015-07-18 10:37:47 +02:00
commit 1e458f186d
8 changed files with 20 additions and 17 deletions

View File

@ -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']);

View File

@ -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:

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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 = [

View File

@ -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;
}

View File

@ -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');

View File

@ -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'];