mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Implement the arcanist top-level log handling in terms of $console->writeLog()
Summary: - See D3422. - Also improve some event configuration/debugging stuff. Test Plan: Ran `arc list --trace`, set bogus/valid event handlers. Reviewers: vrana, nh Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D3423
This commit is contained in:
parent
a309e5e1eb
commit
bc96d6036e
2 changed files with 42 additions and 27 deletions
|
@ -66,12 +66,12 @@ $console = PhutilConsole::getConsole();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ($config_trace_mode) {
|
$console->writeLog(
|
||||||
$phutil_location = phutil_get_library_root('phutil');
|
"libphutil loaded from '%s'.\n",
|
||||||
$arcanist_location = phutil_get_library_root('arcanist');
|
phutil_get_library_root('phutil'));
|
||||||
$console->writeErr("libphutil loaded from '{$phutil_location}'.\n");
|
$console->writeLog(
|
||||||
$console->writeErr("arcanist loaded from '{$arcanist_location}'.\n");
|
"arcanist loaded from '%s'.\n",
|
||||||
}
|
phutil_get_library_root('arcanist'));
|
||||||
|
|
||||||
if (!$args) {
|
if (!$args) {
|
||||||
throw new ArcanistUsageException("No command provided. Try 'arc help'.");
|
throw new ArcanistUsageException("No command provided. Try 'arc help'.");
|
||||||
|
@ -95,8 +95,7 @@ try {
|
||||||
$load,
|
$load,
|
||||||
$must_load = true,
|
$must_load = true,
|
||||||
$lib_source = 'a "--load-phutil-library" flag',
|
$lib_source = 'a "--load-phutil-library" flag',
|
||||||
$working_copy,
|
$working_copy);
|
||||||
$config_trace_mode);
|
|
||||||
} else {
|
} else {
|
||||||
// Load libraries in system 'load' config. In contrast to global config, we
|
// Load libraries in system 'load' config. In contrast to global config, we
|
||||||
// fail hard here because this file is edited manually, so if 'arc' breaks
|
// fail hard here because this file is edited manually, so if 'arc' breaks
|
||||||
|
@ -105,8 +104,7 @@ try {
|
||||||
idx($system_config, 'load', array()),
|
idx($system_config, 'load', array()),
|
||||||
$must_load = true,
|
$must_load = true,
|
||||||
$lib_source = 'the "load" setting in system config',
|
$lib_source = 'the "load" setting in system config',
|
||||||
$working_copy,
|
$working_copy);
|
||||||
$config_trace_mode);
|
|
||||||
|
|
||||||
// Load libraries in global 'load' config, as per "arc set-config load". We
|
// Load libraries in global 'load' config, as per "arc set-config load". We
|
||||||
// need to fail softly if these break because errors would prevent the user
|
// need to fail softly if these break because errors would prevent the user
|
||||||
|
@ -115,16 +113,14 @@ try {
|
||||||
idx($global_config, 'load', array()),
|
idx($global_config, 'load', array()),
|
||||||
$must_load = false,
|
$must_load = false,
|
||||||
$lib_source = 'the "load" setting in global config',
|
$lib_source = 'the "load" setting in global config',
|
||||||
$working_copy,
|
$working_copy);
|
||||||
$config_trace_mode);
|
|
||||||
|
|
||||||
// Load libraries in ".arcconfig". Libraries here must load.
|
// Load libraries in ".arcconfig". Libraries here must load.
|
||||||
arcanist_load_libraries(
|
arcanist_load_libraries(
|
||||||
$working_copy->getConfig('load'),
|
$working_copy->getConfig('load'),
|
||||||
$must_load = true,
|
$must_load = true,
|
||||||
$lib_source = 'the "load" setting in ".arcconfig"',
|
$lib_source = 'the "load" setting in ".arcconfig"',
|
||||||
$working_copy,
|
$working_copy);
|
||||||
$config_trace_mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_config = ArcanistBaseWorkflow::readUserConfigurationFile();
|
$user_config = ArcanistBaseWorkflow::readUserConfigurationFile();
|
||||||
|
@ -161,9 +157,10 @@ try {
|
||||||
if (ArcanistAliasWorkflow::isShellCommandAlias($new_command)) {
|
if (ArcanistAliasWorkflow::isShellCommandAlias($new_command)) {
|
||||||
$shell_cmd = substr($full_alias, 1);
|
$shell_cmd = substr($full_alias, 1);
|
||||||
|
|
||||||
if ($config_trace_mode) {
|
$console->writeLog(
|
||||||
echo "[alias: 'arc {$command}' -> \$ {$full_alias}]\n";
|
"[alias: 'arc %s' -> $ %s]",
|
||||||
}
|
$command,
|
||||||
|
$shell_cmd);
|
||||||
|
|
||||||
if ($args) {
|
if ($args) {
|
||||||
$err = phutil_passthru('%C %Ls', $shell_cmd, $args);
|
$err = phutil_passthru('%C %Ls', $shell_cmd, $args);
|
||||||
|
@ -178,9 +175,10 @@ try {
|
||||||
if ($new_command) {
|
if ($new_command) {
|
||||||
$workflow = $config->buildWorkflow($new_command);
|
$workflow = $config->buildWorkflow($new_command);
|
||||||
if ($workflow) {
|
if ($workflow) {
|
||||||
if ($config_trace_mode) {
|
$console->writeLog(
|
||||||
echo "[alias: 'arc {$command}' -> 'arc {$full_alias}']\n";
|
"[alias: 'arc %s' -> 'arc %s']\n",
|
||||||
}
|
$command,
|
||||||
|
$full_alias);
|
||||||
$command = $new_command;
|
$command = $new_command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,10 +294,22 @@ try {
|
||||||
$workflow->setRepositoryAPI($repository_api);
|
$workflow->setRepositoryAPI($repository_api);
|
||||||
}
|
}
|
||||||
|
|
||||||
$listeners = $working_copy->getConfig('events.listeners');
|
$listeners = $working_copy->getConfigFromAnySource('events.listeners');
|
||||||
if ($listeners) {
|
if ($listeners) {
|
||||||
foreach ($listeners as $listener) {
|
foreach ($listeners as $listener) {
|
||||||
|
$console->writeLog(
|
||||||
|
"Registering event listener '%s'.\n",
|
||||||
|
$listener);
|
||||||
|
try {
|
||||||
id(new $listener())->register();
|
id(new $listener())->register();
|
||||||
|
} catch (PhutilMissingSymbolException $ex) {
|
||||||
|
// Continue anwyay, since you may otherwise be unable to run commands
|
||||||
|
// like `arc set-config events.listeners in order to repair the damage
|
||||||
|
// you've caused.
|
||||||
|
$console->writeErr(
|
||||||
|
"ERROR: Failed to load event listener '%s'!\n",
|
||||||
|
$listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,8 +449,7 @@ function arcanist_load_libraries(
|
||||||
$load,
|
$load,
|
||||||
$must_load,
|
$must_load,
|
||||||
$lib_source,
|
$lib_source,
|
||||||
ArcanistWorkingCopyIdentity $working_copy,
|
ArcanistWorkingCopyIdentity $working_copy) {
|
||||||
$config_trace_mode) {
|
|
||||||
|
|
||||||
if (!$load) {
|
if (!$load) {
|
||||||
return;
|
return;
|
||||||
|
@ -495,9 +504,10 @@ function arcanist_load_libraries(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config_trace_mode) {
|
$console = PhutilConsole::getConsole();
|
||||||
echo "Loading phutil library from '{$location}'...\n";
|
$console->writeLog(
|
||||||
}
|
"Loading phutil library from '%s'...\n",
|
||||||
|
$location);
|
||||||
|
|
||||||
$error = null;
|
$error = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -87,6 +87,11 @@ final class ArcanistSettings {
|
||||||
"'vim'. This setting overrides the EDITOR environmental variable.",
|
"'vim'. This setting overrides the EDITOR environmental variable.",
|
||||||
'example' => '"nano"',
|
'example' => '"nano"',
|
||||||
),
|
),
|
||||||
|
'events.listeners' => array(
|
||||||
|
'type' => 'list',
|
||||||
|
'help' => 'List of event listener classes to install at startup.',
|
||||||
|
'example' => '["ExampleEventListener"]',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue