mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Make the success message from "bin/config" more clear
Summary: Ref T13373. When you "bin/config set x ..." a value, the success message ("Set x ...") is somewhat ambiguous and can be interpreted as "First, you need to set x..." rather than "Success, wrote x...". Make the messaging more explicit. Also make this string more translatable. Test Plan: Ran `bin/config set ...` with various combinations of flags, saw more clear messaging. Maniphest Tasks: T13373 Differential Revision: https://secure.phabricator.com/D20711
This commit is contained in:
parent
c092492a53
commit
006cb659cb
2 changed files with 33 additions and 16 deletions
|
@ -30,11 +30,10 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(PhutilArgumentParser $args) {
|
public function execute(PhutilArgumentParser $args) {
|
||||||
$console = PhutilConsole::getConsole();
|
|
||||||
$argv = $args->getArg('args');
|
$argv = $args->getArg('args');
|
||||||
if (count($argv) == 0) {
|
if (!$argv) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht('Specify a configuration key and a value to set it to.'));
|
pht('Specify the configuration key you want to set.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_stdin = $args->getArg('stdin');
|
$is_stdin = $args->getArg('stdin');
|
||||||
|
@ -45,7 +44,8 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
if (count($argv) > 1) {
|
if (count($argv) > 1) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht(
|
pht(
|
||||||
'Too many arguments: expected only a key when using "--stdin".'));
|
'Too many arguments: expected only a configuration key when '.
|
||||||
|
'using "--stdin".'));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(STDERR, tsprintf("%s\n", pht('Reading value from stdin...')));
|
fprintf(STDERR, tsprintf("%s\n", pht('Reading value from stdin...')));
|
||||||
|
@ -54,7 +54,8 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
if (count($argv) == 1) {
|
if (count($argv) == 1) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht(
|
pht(
|
||||||
"Specify a value to set the key '%s' to.",
|
'Specify a value to set the configuration key "%s" to, or '.
|
||||||
|
'use "--stdin" to read a value from stdin.',
|
||||||
$key));
|
$key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,14 +68,13 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
$value = $argv[1];
|
$value = $argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
|
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
|
||||||
if (empty($options[$key])) {
|
if (empty($options[$key])) {
|
||||||
throw new PhutilArgumentUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht(
|
pht(
|
||||||
"No such configuration key '%s'! Use `%s` to list all keys.",
|
'Configuration key "%s" is unknown. Use "bin/config list" to list '.
|
||||||
$key,
|
'all known keys.',
|
||||||
'config list'));
|
$key));
|
||||||
}
|
}
|
||||||
|
|
||||||
$option = $options[$key];
|
$option = $options[$key];
|
||||||
|
@ -99,7 +99,7 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
default:
|
default:
|
||||||
$message = pht(
|
$message = pht(
|
||||||
'Config key "%s" is of type "%s". Specify it in JSON.',
|
'Configuration key "%s" is of type "%s". Specify it in JSON.',
|
||||||
$key,
|
$key,
|
||||||
$type);
|
$type);
|
||||||
break;
|
break;
|
||||||
|
@ -128,7 +128,6 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_database) {
|
if ($use_database) {
|
||||||
$config_type = 'database';
|
|
||||||
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
|
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
|
||||||
$config_entry->setValue($value);
|
$config_entry->setValue($value);
|
||||||
|
|
||||||
|
@ -136,15 +135,28 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
$config_entry->setIsDeleted(0);
|
$config_entry->setIsDeleted(0);
|
||||||
|
|
||||||
$config_entry->save();
|
$config_entry->save();
|
||||||
|
|
||||||
|
$write_message = pht(
|
||||||
|
'Wrote configuration key "%s" to database storage.',
|
||||||
|
$key);
|
||||||
} else {
|
} else {
|
||||||
$config_type = 'local';
|
$config_source = id(new PhabricatorConfigLocalSource())
|
||||||
id(new PhabricatorConfigLocalSource())
|
|
||||||
->setKeys(array($key => $value));
|
->setKeys(array($key => $value));
|
||||||
|
|
||||||
|
$local_path = $config_source->getReadablePath();
|
||||||
|
|
||||||
|
$write_message = pht(
|
||||||
|
'Wrote configuration key "%s" to local storage (in file "%s").',
|
||||||
|
$key,
|
||||||
|
$local_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$console->writeOut(
|
echo tsprintf(
|
||||||
"%s\n",
|
"<bg:green>** %s **</bg> %s\n",
|
||||||
pht("Set '%s' in %s configuration.", $key, $config_type));
|
pht('DONE'),
|
||||||
|
$write_message);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,4 +65,9 @@ final class PhabricatorConfigLocalSource extends PhabricatorConfigProxySource {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getReadablePath() {
|
||||||
|
$path = $this->getConfigPath();
|
||||||
|
return Filesystem::readablePath($path);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue