aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Config/App/GetConfig.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Config/App/GetConfig.php')
-rw-r--r--core/Command/Config/App/GetConfig.php69
1 files changed, 37 insertions, 32 deletions
diff --git a/core/Command/Config/App/GetConfig.php b/core/Command/Config/App/GetConfig.php
index 7fdff2be732..af0c5648232 100644
--- a/core/Command/Config/App/GetConfig.php
+++ b/core/Command/Config/App/GetConfig.php
@@ -1,40 +1,20 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\Config\App;
-use OCP\IConfig;
+use OCP\Exceptions\AppConfigUnknownKeyException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class GetConfig extends Base {
- protected IConfig $config;
-
- public function __construct(IConfig $config) {
- parent::__construct();
- $this->config = $config;
- }
-
protected function configure() {
parent::configure();
@@ -52,6 +32,18 @@ class GetConfig extends Base {
'Name of the config to get'
)
->addOption(
+ 'details',
+ null,
+ InputOption::VALUE_NONE,
+ 'returns complete details about the app config value'
+ )
+ ->addOption(
+ '--key-details',
+ null,
+ InputOption::VALUE_NONE,
+ 'returns complete details about the app config key'
+ )
+ ->addOption(
'default-value',
null,
InputOption::VALUE_OPTIONAL,
@@ -63,7 +55,7 @@ class GetConfig extends Base {
/**
* Executes the current command.
*
- * @param InputInterface $input An InputInterface instance
+ * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return int 0 if everything went fine, or an error code
*/
@@ -72,14 +64,27 @@ class GetConfig extends Base {
$configName = $input->getArgument('name');
$defaultValue = $input->getOption('default-value');
- if (!in_array($configName, $this->config->getAppKeys($appName)) && !$input->hasParameterOption('--default-value')) {
- return 1;
+ if ($input->getOption('details')) {
+ $details = $this->appConfig->getDetails($appName, $configName);
+ $details['type'] = $details['typeString'];
+ unset($details['typeString']);
+ $this->writeArrayInOutputFormat($input, $output, $details);
+ return 0;
+ }
+
+ if ($input->getOption('key-details')) {
+ $details = $this->appConfig->getKeyDetails($appName, $configName);
+ $this->writeArrayInOutputFormat($input, $output, $details);
+ return 0;
}
- if (!in_array($configName, $this->config->getAppKeys($appName))) {
+ try {
+ $configValue = $this->appConfig->getDetails($appName, $configName)['value'];
+ } catch (AppConfigUnknownKeyException $e) {
+ if (!$input->hasParameterOption('--default-value')) {
+ return 1;
+ }
$configValue = $defaultValue;
- } else {
- $configValue = $this->config->getAppValue($appName, $configName);
}
$this->writeMixedInOutputFormat($input, $output, $configValue);