Differential D18157 Diff 43703 src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | public function execute(PhutilArgumentParser $args) { | ||||
$option = $options[$key]; | $option = $options[$key]; | ||||
$type = $option->newOptionType(); | $type = $option->newOptionType(); | ||||
if ($type) { | if ($type) { | ||||
try { | try { | ||||
$value = $type->newValueFromCommandLineValue( | $value = $type->newValueFromCommandLineValue( | ||||
$option, | $option, | ||||
$value); | $value); | ||||
$type->validateStoredValue($option, $value); | |||||
} catch (PhabricatorConfigValidationException $ex) { | } catch (PhabricatorConfigValidationException $ex) { | ||||
throw new PhutilArgumentUsageException($ex->getMessage()); | throw new PhutilArgumentUsageException($ex->getMessage()); | ||||
} | } | ||||
} else { | } else { | ||||
$type = $option->getType(); | $type = $option->getType(); | ||||
switch ($type) { | switch ($type) { | ||||
case 'class': | case 'class': | ||||
$value = (string)$value; | $value = (string)$value; | ||||
Show All 28 Lines | if ($type) { | ||||
pht( | pht( | ||||
'Config key "%s" is of type "%s". Specify it in JSON. '. | 'Config key "%s" is of type "%s". Specify it in JSON. '. | ||||
'For example:', | 'For example:', | ||||
$key, | $key, | ||||
$type), | $type), | ||||
$command); | $command); | ||||
break; | break; | ||||
default: | default: | ||||
if (preg_match('/^list</', $type)) { | |||||
$command = csprintf( | |||||
'./bin/config set %R %s', | |||||
$key, | |||||
'["a", "b", "c"]'); | |||||
$message = sprintf( | |||||
"%s\n\n %s\n", | |||||
pht( | |||||
'Config key "%s" is of type "%s". Specify it in JSON. '. | |||||
'For example:', | |||||
$key, | |||||
$type), | |||||
$command); | |||||
} else { | |||||
$message = pht( | $message = pht( | ||||
'Config key "%s" is of type "%s". Specify it in JSON.', | 'Config key "%s" is of type "%s". Specify it in JSON.', | ||||
$key, | $key, | ||||
$type); | $type); | ||||
} | |||||
break; | break; | ||||
} | } | ||||
throw new PhutilArgumentUsageException($message); | throw new PhutilArgumentUsageException($message); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
Show All 38 Lines |