Changeset View
Changeset View
Standalone View
Standalone View
src/runtime/ArcanistRuntime.php
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | $config_args = array( | ||||
'param' => 'path', | 'param' => 'path', | ||||
'repeat' => true, | 'repeat' => true, | ||||
'help' => pht( | 'help' => pht( | ||||
'Load one or more configuration files. If this flag is provided, '. | 'Load one or more configuration files. If this flag is provided, '. | ||||
'the system and user configuration files are ignored.'), | 'the system and user configuration files are ignored.'), | ||||
), | ), | ||||
); | ); | ||||
$args = id(new PhutilArgumentParser($argv)) | $args = (new PhutilArgumentParser($argv)) | ||||
->parseStandardArguments(); | ->parseStandardArguments(); | ||||
// If we can test whether STDIN is a TTY, and it isn't, require that "--" | // If we can test whether STDIN is a TTY, and it isn't, require that "--" | ||||
// appear in the argument list. This is intended to make it very hard to | // appear in the argument list. This is intended to make it very hard to | ||||
// write unsafe scripts on top of Arcanist. | // write unsafe scripts on top of Arcanist. | ||||
if (phutil_is_noninteractive()) { | if (phutil_is_noninteractive()) { | ||||
$args->setRequireArgumentTerminator(true); | $args->setRequireArgumentTerminator(true); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (!$unconsumed_argv) { | ||||
// of the toolset, a list of workflows, and a pointer to "arc help" for | // of the toolset, a list of workflows, and a pointer to "arc help" for | ||||
// more details. | // more details. | ||||
// A possible exception is "arc --help", which should perhaps pass | // A possible exception is "arc --help", which should perhaps pass | ||||
// through and act like "arc help". | // through and act like "arc help". | ||||
throw new PhutilArgumentUsageException(pht('Choose a workflow!')); | throw new PhutilArgumentUsageException(pht('Choose a workflow!')); | ||||
} | } | ||||
$alias_effects = id(new ArcanistAliasEngine()) | $alias_effects = (new ArcanistAliasEngine()) | ||||
->setRuntime($this) | ->setRuntime($this) | ||||
->setToolset($toolset) | ->setToolset($toolset) | ||||
->setWorkflows($workflows) | ->setWorkflows($workflows) | ||||
->setConfigurationSourceList($config) | ->setConfigurationSourceList($config) | ||||
->resolveAliases($unconsumed_argv); | ->resolveAliases($unconsumed_argv); | ||||
foreach ($alias_effects as $alias_effect) { | foreach ($alias_effects as $alias_effect) { | ||||
if ($alias_effect->getType() === ArcanistAliasEffect::EFFECT_SHELL) { | if ($alias_effect->getType() === ArcanistAliasEffect::EFFECT_SHELL) { | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | if ($problems) { | ||||
} | } | ||||
$problems = implode("\n\n", $problems); | $problems = implode("\n\n", $problems); | ||||
throw new Exception($problems); | throw new Exception($problems); | ||||
} | } | ||||
} | } | ||||
private function loadConfiguration(PhutilArgumentParser $args) { | private function loadConfiguration(PhutilArgumentParser $args) { | ||||
$engine = id(new ArcanistConfigurationEngine()) | $engine = (new ArcanistConfigurationEngine()) | ||||
->setArguments($args); | ->setArguments($args); | ||||
$working_copy = ArcanistWorkingCopy::newFromWorkingDirectory(getcwd()); | $working_copy = ArcanistWorkingCopy::newFromWorkingDirectory(getcwd()); | ||||
$engine->setWorkingCopy($working_copy); | $engine->setWorkingCopy($working_copy); | ||||
$this->workingCopy = $working_copy; | $this->workingCopy = $working_copy; | ||||
▲ Show 20 Lines • Show All 144 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__); | ||||
$log->writeWarn( | $log->writeWarn( | ||||
pht('VERY META'), | pht('VERY META'), | ||||
pht( | pht( | ||||
'You are running one copy of this software (at path "%s") against '. | 'You are running one copy of this software (at path "%s") against '. | ||||
'another copy of this software (at path "%s"). Code in the current '. | 'another copy of this software (at path "%s"). Code in the current '. | ||||
'working directory will not be loaded or executed.', | 'working directory will not be loaded or executed.', | ||||
$executing_directory, | $executing_directory, | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (!isset($toolsets[$binary])) { | ||||
$binary, | $binary, | ||||
implode(', ', array_keys($toolsets)))); | implode(', ', array_keys($toolsets)))); | ||||
} | } | ||||
return $toolsets[$binary]; | return $toolsets[$binary]; | ||||
} | } | ||||
private function newWorkflows(ArcanistToolset $toolset) { | private function newWorkflows(ArcanistToolset $toolset) { | ||||
$workflows = id(new PhutilClassMapQuery()) | $workflows = (new PhutilClassMapQuery()) | ||||
->setAncestorClass('ArcanistWorkflow') | ->setAncestorClass('ArcanistWorkflow') | ||||
->setContinueOnFailure(true) | ->setContinueOnFailure(true) | ||||
->execute(); | ->execute(); | ||||
foreach ($workflows as $key => $workflow) { | foreach ($workflows as $key => $workflow) { | ||||
if (!$workflow->supportsToolset($toolset)) { | if (!$workflow->supportsToolset($toolset)) { | ||||
unset($workflows[$key]); | unset($workflows[$key]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | final class ArcanistRuntime { | ||||
public function getSymbolEngine() { | public function getSymbolEngine() { | ||||
if ($this->symbolEngine === null) { | if ($this->symbolEngine === null) { | ||||
$this->symbolEngine = $this->newSymbolEngine(); | $this->symbolEngine = $this->newSymbolEngine(); | ||||
} | } | ||||
return $this->symbolEngine; | return $this->symbolEngine; | ||||
} | } | ||||
private function newSymbolEngine() { | private function newSymbolEngine() { | ||||
return id(new ArcanistSymbolEngine()) | return (new ArcanistSymbolEngine()) | ||||
->setWorkflow($this); | ->setWorkflow($this); | ||||
} | } | ||||
public function getHardpointEngine() { | public function getHardpointEngine() { | ||||
if ($this->hardpointEngine === null) { | if ($this->hardpointEngine === null) { | ||||
$this->hardpointEngine = $this->newHardpointEngine(); | $this->hardpointEngine = $this->newHardpointEngine(); | ||||
} | } | ||||
return $this->hardpointEngine; | return $this->hardpointEngine; | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 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