Changeset View
Changeset View
Standalone View
Standalone View
scripts/arcanist.php
#!/usr/bin/env php | #!/usr/bin/env php | ||||
<?php | <?php | ||||
sanity_check_environment(); | sanity_check_environment(); | ||||
require_once dirname(__FILE__).'/__init_script__.php'; | require_once __DIR__.'/__init_script__.php'; | ||||
/** | /** | ||||
* Adjust 'include_path' to add locations where we'll search for libraries. | * Adjust 'include_path' to add locations where we'll search for libraries. | ||||
* We look in these places: | * We look in these places: | ||||
* | * | ||||
* - Next to 'arcanist/'. | * - Next to 'arcanist/'. | ||||
* - Anywhere in the normal PHP 'include_path'. | * - Anywhere in the normal PHP 'include_path'. | ||||
* - Inside 'arcanist/externals/includes/'. | * - Inside 'arcanist/externals/includes/'. | ||||
*/ | */ | ||||
function arcanist_adjust_php_include_path() { | function arcanist_adjust_php_include_path() { | ||||
// The 'arcanist/' directory. | // The 'arcanist/' directory. | ||||
$arcanist_dir = dirname(dirname(__FILE__)); | $arcanist_dir = dirname(__DIR__); | ||||
// The parent directory of 'arcanist/'. | // The parent directory of 'arcanist/'. | ||||
$parent_dir = dirname($arcanist_dir); | $parent_dir = dirname($arcanist_dir); | ||||
// The 'arcanist/externals/includes/' directory. | // The 'arcanist/externals/includes/' directory. | ||||
$include_dir = implode( | $include_dir = implode( | ||||
DIRECTORY_SEPARATOR, | DIRECTORY_SEPARATOR, | ||||
array( | array( | ||||
▲ Show 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | try { | ||||
$credentials = array( | $credentials = array( | ||||
'user' => $user_name, | 'user' => $user_name, | ||||
'certificate' => $certificate, | 'certificate' => $certificate, | ||||
'description' => $description, | 'description' => $description, | ||||
'token' => $conduit_token, | 'token' => $conduit_token, | ||||
); | ); | ||||
$workflow->setConduitCredentials($credentials); | $workflow->setConduitCredentials($credentials); | ||||
$engine = id(new ArcanistConduitEngine()) | $engine = (new ArcanistConduitEngine()) | ||||
->setConduitURI($conduit_uri) | ->setConduitURI($conduit_uri) | ||||
->setConduitToken($conduit_token); | ->setConduitToken($conduit_token); | ||||
$workflow->setConduitEngine($engine); | $workflow->setConduitEngine($engine); | ||||
if ($need_auth) { | if ($need_auth) { | ||||
if ((!$user_name || !$certificate) && (!$conduit_token)) { | if ((!$user_name || !$certificate) && (!$conduit_token)) { | ||||
$arc = 'arc'; | $arc = 'arc'; | ||||
if ($force_conduit) { | if ($force_conduit) { | ||||
$arc .= csprintf(' --conduit-uri=%s', $conduit_uri); | $arc .= csprintf(' --conduit-uri=%s', $conduit_uri); | ||||
} | } | ||||
$conduit_domain = id(new PhutilURI($conduit_uri))->getDomain(); | $conduit_domain = (new PhutilURI($conduit_uri))->getDomain(); | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
phutil_console_format( | phutil_console_format( | ||||
"%s\n\n%s\n\n%s **%s:**\n\n $ **{$arc} install-certificate**\n", | "%s\n\n%s\n\n%s **%s:**\n\n $ **{$arc} install-certificate**\n", | ||||
pht('YOU NEED TO AUTHENTICATE TO CONTINUE'), | pht('YOU NEED TO AUTHENTICATE TO CONTINUE'), | ||||
pht( | pht( | ||||
'You are trying to connect to a server (%s) that you '. | 'You are trying to connect to a server (%s) that you '. | ||||
'do not have any credentials stored for.', | 'do not have any credentials stored for.', | ||||
Show All 14 Lines | try { | ||||
$listeners = $configuration_manager->getConfigFromAnySource( | $listeners = $configuration_manager->getConfigFromAnySource( | ||||
'events.listeners'); | 'events.listeners'); | ||||
if ($listeners) { | if ($listeners) { | ||||
foreach ($listeners as $listener) { | foreach ($listeners as $listener) { | ||||
$console->writeLog( | $console->writeLog( | ||||
"%s\n", | "%s\n", | ||||
pht("Registering event listener '%s'.", $listener)); | pht("Registering event listener '%s'.", $listener)); | ||||
try { | try { | ||||
id(new $listener())->register(); | (new $listener())->register(); | ||||
} catch (PhutilMissingSymbolException $ex) { | } catch (PhutilMissingSymbolException $ex) { | ||||
// Continue anyway, since you may otherwise be unable to run commands | // Continue anyway, since you may otherwise be unable to run commands | ||||
// like `arc set-config events.listeners` in order to repair the damage | // like `arc set-config events.listeners` in order to repair the damage | ||||
// you've caused. We're writing out the entire exception here because | // you've caused. We're writing out the entire exception here because | ||||
// it might not have been triggered by the listener itself (for example, | // it might not have been triggered by the listener itself (for example, | ||||
// the listener might use a bad class in its register() method). | // the listener might use a bad class in its register() method). | ||||
$console->writeErr( | $console->writeErr( | ||||
"%s\n", | "%s\n", | ||||
▲ Show 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | try { | ||||
// This means we only execute code in the `arcanist/` directory which is | // This means we only execute code in the `arcanist/` directory which is | ||||
// associated with the binary you are running, whereas we would normally | // associated with the binary you are running, whereas we would normally | ||||
// execute local code. | // execute local code. | ||||
// This can make `arc` development slightly confusing if your setup is | // This can make `arc` development slightly confusing if your setup is | ||||
// especially bizarre, but it allows `arc` to be used in automation | // especially bizarre, but it allows `arc` to be used in automation | ||||
// workflows more easily. For some context, see PHI13. | // workflows more easily. For some context, see PHI13. | ||||
$executing_directory = dirname(dirname(__FILE__)); | $executing_directory = dirname(__DIR__); | ||||
$working_directory = dirname($location); | $working_directory = dirname($location); | ||||
fwrite( | fwrite( | ||||
STDERR, | STDERR, | ||||
tsprintf( | tsprintf( | ||||
"**<bg:yellow> %s </bg>** %s\n", | "**<bg:yellow> %s </bg>** %s\n", | ||||
pht('VERY META'), | pht('VERY META'), | ||||
pht( | pht( | ||||
Show All 10 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0