3 final class PhabricatorConfigManagementGetWorkflow
4 extends PhabricatorConfigManagementWorkflow
{
6 protected function didConstruct() {
9 ->setExamples('**get** __key__')
10 ->setSynopsis(pht('Get a local configuration value.'))
20 public function execute(PhutilArgumentParser
$args) {
21 $console = PhutilConsole
::getConsole();
23 $argv = $args->getArg('args');
24 if (count($argv) == 0) {
25 throw new PhutilArgumentUsageException(
26 pht('Specify a configuration key to get.'));
31 if (count($argv) > 1) {
32 throw new PhutilArgumentUsageException(
33 pht('Too many arguments: expected one key.'));
36 $options = PhabricatorApplicationConfigOptions
::loadAllOptions();
37 if (empty($options[$key])) {
38 throw new PhutilArgumentUsageException(
40 "No such configuration key '%s'! Use `%s` to list all keys.",
46 $config = new PhabricatorConfigLocalSource();
47 $local_value = $config->getKeys(array($key));
48 if (empty($local_value)) {
49 $values['local'] = array(
56 $values['local'] = array(
58 'value' => reset($local_value),
65 $database_config = new PhabricatorConfigDatabaseSource('default');
66 $database_value = $database_config->getKeys(array($key));
67 if (empty($database_value)) {
68 $values['database'] = array(
75 $values['database'] = array(
77 'value' => reset($database_value),
82 } catch (Exception
$e) {
83 $values['database'] = array(
87 'errorInfo' => pht('Database source is not configured properly'),
92 foreach ($values as $source => $value) {
94 'key' => $value['key'],
96 'value' => $value['value'],
97 'status' => $value['status'],
98 'errorInfo' => $value['errorInfo'],
105 $json = new PhutilJSON();
106 $console->writeOut($json->encodeFormatted($result));