-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Maxence Lange <[email protected]>
- Loading branch information
1 parent
32bf74a
commit c1ad25a
Showing
24 changed files
with
2,304 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2016, ownCloud, Inc. | ||
* | ||
* @author Joas Schilling <[email protected]> | ||
* @author Maxence Lange <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
|
@@ -21,15 +24,16 @@ | |
*/ | ||
namespace OC\Core\Command\Config\App; | ||
|
||
use OCP\IConfig; | ||
use OCP\Exceptions\AppConfigUnknownKeyException; | ||
use OCP\IAppConfig; | ||
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 { | ||
public function __construct( | ||
protected IConfig $config, | ||
protected IAppConfig $appConfig, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
@@ -50,6 +54,12 @@ protected function configure() { | |
InputArgument::REQUIRED, | ||
'Name of the config to get' | ||
) | ||
->addOption( | ||
'details', | ||
null, | ||
InputOption::VALUE_NONE, | ||
'returns complete details about the app config value' | ||
) | ||
->addOption( | ||
'default-value', | ||
null, | ||
|
@@ -71,14 +81,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
$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 (!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); | ||
|
Oops, something went wrong.