diff --git a/core/command/app/listapps.php b/core/command/app/listapps.php index e30baddb7457cfc6344696c294293a4f039b58b3..e483037d45d4349df37b7dd38e2e2385c315d81f 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 7e61c0cb9ab262b9f5c09c4949ee956804c32d61..0a4b002c1ca96cb078bafb0a31c5ef3674a2d6ca 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 0031142358e4bf9e3eb875f68c770e4f1bfe5304..bc031b0d589ec58dec96a1e06421e48b6dae4358 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 91775094fdd8bd2c259d9f885913cf80bd1bc82b..eea58a63c5ed1b27cb860c9898ef1de3c4d1031a 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 be3073e54d98f168e590a84f5c30b32ae93df853..fed6a8e9db6cd65959304cf3356a8fcc2f1c88c3 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 49bc2bc8c0304c2d0e21761f9194f0a25ebdd0a4..4d193647c85f6158bdc34543275ee726f43694ae 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 cb2f9fe616fa16606f8d5a422fbdd438965cc641..82b36cca1649b0a2df62f00e7f48af1deb7c97ab 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 d55480def87c513fd6174f69554feb062c3ddab6..cc436ea5629f2bb1daeb7e4868b82ab5904d3bad 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'];