mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Allow specifying runtime configuration with --set-config key=value
Summary: This is useful for wrapper scripts that want to customize arcanist's behavior without affecting the global configuration. This can be implemented with arcanist_configuration entry in .arcconfig, however it is currently limited to per-project settings, and this feature makes writing wrapper scripts a little easier. Test Plan: arc diff --set-config editor=vim (yeah yeah, crappy test case) Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9442
This commit is contained in:
parent
2ccf65353c
commit
5a02012706
4 changed files with 56 additions and 16 deletions
|
@ -8,9 +8,9 @@ require_once dirname(__FILE__).'/__init_script__.php';
|
||||||
ini_set('memory_limit', -1);
|
ini_set('memory_limit', -1);
|
||||||
|
|
||||||
$original_argv = $argv;
|
$original_argv = $argv;
|
||||||
$args = new PhutilArgumentParser($argv);
|
$base_args = new PhutilArgumentParser($argv);
|
||||||
$args->parseStandardArguments();
|
$base_args->parseStandardArguments();
|
||||||
$args->parsePartial(
|
$base_args->parsePartial(
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
'name' => 'load-phutil-library',
|
'name' => 'load-phutil-library',
|
||||||
|
@ -40,20 +40,26 @@ $args->parsePartial(
|
||||||
'param' => 'timeout',
|
'param' => 'timeout',
|
||||||
'help' => 'Set Conduit timeout (in seconds).',
|
'help' => 'Set Conduit timeout (in seconds).',
|
||||||
),
|
),
|
||||||
));
|
array(
|
||||||
|
'name' => 'config',
|
||||||
|
'param' => 'key=value',
|
||||||
|
'repeat' => true,
|
||||||
|
'help' =>
|
||||||
|
'Specify a runtime configuration value. This will take precedence '.
|
||||||
|
'over static values, and only affect the current arcanist invocation.'
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
$config_trace_mode = $args->getArg('trace');
|
$config_trace_mode = $base_args->getArg('trace');
|
||||||
|
|
||||||
$force_conduit = $args->getArg('conduit-uri');
|
$force_conduit = $base_args->getArg('conduit-uri');
|
||||||
$force_conduit_version = $args->getArg('conduit-version');
|
$force_conduit_version = $base_args->getArg('conduit-version');
|
||||||
$conduit_timeout = $args->getArg('conduit-timeout');
|
$conduit_timeout = $base_args->getArg('conduit-timeout');
|
||||||
$skip_arcconfig = $args->getArg('skip-arcconfig');
|
$skip_arcconfig = $base_args->getArg('skip-arcconfig');
|
||||||
$custom_arcrc = $args->getArg('arcrc-file');
|
$custom_arcrc = $base_args->getArg('arcrc-file');
|
||||||
$load = $args->getArg('load-phutil-library');
|
$load = $base_args->getArg('load-phutil-library');
|
||||||
$help = $args->getArg('help');
|
$help = $base_args->getArg('help');
|
||||||
|
$args = array_values($base_args->getUnconsumedArgumentVector());
|
||||||
$argv = $args->getUnconsumedArgumentVector();
|
|
||||||
$args = array_values($argv);
|
|
||||||
|
|
||||||
$working_directory = getcwd();
|
$working_directory = getcwd();
|
||||||
$console = PhutilConsole::getConsole();
|
$console = PhutilConsole::getConsole();
|
||||||
|
@ -86,6 +92,8 @@ try {
|
||||||
|
|
||||||
$global_config = $configuration_manager->readUserArcConfig();
|
$global_config = $configuration_manager->readUserArcConfig();
|
||||||
$system_config = $configuration_manager->readSystemArcConfig();
|
$system_config = $configuration_manager->readSystemArcConfig();
|
||||||
|
$runtime_config = $configuration_manager->applyRuntimeArcConfig($base_args);
|
||||||
|
|
||||||
if ($skip_arcconfig) {
|
if ($skip_arcconfig) {
|
||||||
$working_copy = ArcanistWorkingCopyIdentity::newDummyWorkingCopy();
|
$working_copy = ArcanistWorkingCopyIdentity::newDummyWorkingCopy();
|
||||||
} else {
|
} else {
|
||||||
|
@ -142,6 +150,14 @@ try {
|
||||||
$must_load = true,
|
$must_load = true,
|
||||||
$lib_source = 'the "load" setting in ".arcconfig"',
|
$lib_source = 'the "load" setting in ".arcconfig"',
|
||||||
$working_copy);
|
$working_copy);
|
||||||
|
|
||||||
|
// Load libraries in ".arcconfig". Libraries here must load.
|
||||||
|
arcanist_load_libraries(
|
||||||
|
idx($runtime_config, 'load', array()),
|
||||||
|
$must_load = true,
|
||||||
|
$lib_source = 'the --config "load=[...]" argument',
|
||||||
|
$working_copy);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_config = $configuration_manager->readUserConfigurationFile();
|
$user_config = $configuration_manager->readUserConfigurationFile();
|
||||||
|
|
|
@ -305,7 +305,26 @@ final class ArcanistConfigurationManager {
|
||||||
return $system_config;
|
return $system_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readDefaultConfig() {
|
public function applyRuntimeArcConfig($args) {
|
||||||
|
$arcanist_settings = new ArcanistSettings();
|
||||||
|
$options = $args->getArg('config');
|
||||||
|
|
||||||
|
foreach ($options as $opt) {
|
||||||
|
$opt_config = preg_split('/=/', $opt, 2);
|
||||||
|
if (count($opt_config) !== 2) {
|
||||||
|
throw new ArcanistUsageException("Argument was '{$opt}', but must be ".
|
||||||
|
"'name=value'. For example, history.immutable=true");
|
||||||
|
}
|
||||||
|
|
||||||
|
list($key, $value) = $opt_config;
|
||||||
|
$value = $arcanist_settings->willWriteValue($key, $value);
|
||||||
|
$this->setRuntimeConfig($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->runtimeConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function readDefaultConfig() {
|
||||||
$settings = new ArcanistSettings();
|
$settings = new ArcanistSettings();
|
||||||
return $settings->getDefaultSettings();
|
return $settings->getDefaultSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,6 +594,7 @@ abstract class ArcanistBaseWorkflow extends Phobject {
|
||||||
$arc_config = $this->getArcanistConfiguration();
|
$arc_config = $this->getArcanistConfiguration();
|
||||||
$command = $this->getCommand();
|
$command = $this->getCommand();
|
||||||
$spec += $arc_config->getCustomArgumentsForCommand($command);
|
$spec += $arc_config->getCustomArgumentsForCommand($command);
|
||||||
|
|
||||||
return $spec;
|
return $spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,10 @@ EOTEXT
|
||||||
__--conduit-timeout__ __timeout__
|
__--conduit-timeout__ __timeout__
|
||||||
Override the default Conduit timeout. Specified in seconds.
|
Override the default Conduit timeout. Specified in seconds.
|
||||||
|
|
||||||
|
__--config__ __key=value__
|
||||||
|
Specify a runtime configuration value. This will take precedence
|
||||||
|
over static values, and only affect the current arcanist invocation.
|
||||||
|
|
||||||
__--skip-arcconfig__
|
__--skip-arcconfig__
|
||||||
Skip the working copy configuration file
|
Skip the working copy configuration file
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue