mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Provide "arc look", a user-facing inspection command
Summary: Ref T13546. Currently, "arc which" provides some amount of inspection but it generally isn't very helpful to users and is too limited and inflexible. "arc inspect" is an internal/debugging workflow. The new "arc look" is much more aggressively unhelpful. Test Plan: I'm not sure if this command should allow you to continue at night, because it's too dark. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21376
This commit is contained in:
parent
ffb027e85c
commit
6bf7a40358
3 changed files with 177 additions and 0 deletions
|
@ -325,6 +325,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistLogMessage' => 'log/ArcanistLogMessage.php',
|
||||
'ArcanistLogicalOperatorsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistLogicalOperatorsXHPASTLinterRule.php',
|
||||
'ArcanistLogicalOperatorsXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistLogicalOperatorsXHPASTLinterRuleTestCase.php',
|
||||
'ArcanistLookWorkflow' => 'workflow/ArcanistLookWorkflow.php',
|
||||
'ArcanistLowercaseFunctionsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistLowercaseFunctionsXHPASTLinterRule.php',
|
||||
'ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase.php',
|
||||
'ArcanistMarkerRef' => 'repository/marker/ArcanistMarkerRef.php',
|
||||
|
@ -1354,6 +1355,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistLogMessage' => 'Phobject',
|
||||
'ArcanistLogicalOperatorsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||
'ArcanistLogicalOperatorsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||
'ArcanistLookWorkflow' => 'ArcanistArcWorkflow',
|
||||
'ArcanistLowercaseFunctionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||
'ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||
'ArcanistMarkerRef' => 'ArcanistRef',
|
||||
|
|
|
@ -38,4 +38,8 @@ final class ArcanistRemoteRef
|
|||
return $this->pushURI;
|
||||
}
|
||||
|
||||
protected function buildRefView(ArcanistRefView $view) {
|
||||
$view->setObjectName($this->getRemoteName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
171
src/workflow/ArcanistLookWorkflow.php
Normal file
171
src/workflow/ArcanistLookWorkflow.php
Normal file
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistLookWorkflow
|
||||
extends ArcanistArcWorkflow {
|
||||
|
||||
public function getWorkflowName() {
|
||||
return 'look';
|
||||
}
|
||||
|
||||
public function getWorkflowInformation() {
|
||||
$help = pht(<<<EOTEXT
|
||||
Look around, or look at a specific __thing__.
|
||||
EOTEXT
|
||||
);
|
||||
|
||||
return $this->newWorkflowInformation()
|
||||
->setSynopsis(
|
||||
pht('You stand in the middle of a small clearing.'))
|
||||
->addExample('**look**')
|
||||
->addExample('**look** [options] -- __thing__')
|
||||
->setHelp($help);
|
||||
}
|
||||
|
||||
public function getWorkflowArguments() {
|
||||
return array(
|
||||
$this->newWorkflowArgument('argv')
|
||||
->setWildcard(true),
|
||||
);
|
||||
}
|
||||
|
||||
public function runWorkflow() {
|
||||
echo tsprintf(
|
||||
"%!\n\n",
|
||||
pht(
|
||||
'Arcventure'));
|
||||
|
||||
$argv = $this->getArgument('argv');
|
||||
|
||||
if ($argv) {
|
||||
if ($argv === array('remotes')) {
|
||||
return $this->lookRemotes();
|
||||
}
|
||||
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht(
|
||||
'You do not see "%s" anywhere.',
|
||||
implode(' ', $argv)));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
echo tsprintf(
|
||||
"%W\n\n",
|
||||
pht(
|
||||
'You stand in the middle of a small clearing in the woods.'));
|
||||
|
||||
$now = time();
|
||||
$hour = (int)date('h', $now);
|
||||
|
||||
if ($hour >= 5 && $hour <= 7) {
|
||||
$time = pht(
|
||||
'It is early morning. Glimses of sunlight peek through the trees '.
|
||||
'and you hear the faint sound of birds overhead.');
|
||||
} else if ($hour >= 8 && $hour <= 10) {
|
||||
$time = pht(
|
||||
'It is morning. The sun is high in the sky to the east and you hear '.
|
||||
'birds all around you. A gentle breeze rustles the leaves overhead.');
|
||||
} else if ($hour >= 11 && $hour <= 13) {
|
||||
$time = pht(
|
||||
'It is midday. The sun is high overhead and the air is still. It is '.
|
||||
'very warm. You hear the cry of a hawk high overhead and far in the '.
|
||||
'distance.');
|
||||
} else if ($hour >= 14 && $hour <= 16) {
|
||||
$time = pht(
|
||||
'It is afternoon. The air has changed and it feels as though it '.
|
||||
'may rain. You hear a squirrel chittering high overhead.');
|
||||
} else if ($hour >= 17 && $hour <= 19) {
|
||||
$time = pht(
|
||||
'It is nearly dusk. The wind has picked up and the trees around you '.
|
||||
'sway and rustle.');
|
||||
} else if ($hour >= 21 && $hour <= 23) {
|
||||
$time = pht(
|
||||
'It is late in the evening. The air is cool and still, and filled '.
|
||||
'with the sound of crickets.');
|
||||
} else {
|
||||
$phase = new PhutilLunarPhase($now);
|
||||
if ($phase->isNew()) {
|
||||
$time = pht(
|
||||
'Night has fallen, and the thin sliver of moon overhead offers '.
|
||||
'no comfort. It is almost pitch black. The night is bitter '.
|
||||
'cold. It will be difficult to look around in these conditions.');
|
||||
} else if ($phase->isFull()) {
|
||||
$time = pht(
|
||||
'Night has fallen, but your surroundings are illuminated by the '.
|
||||
'silvery glow of a full moon overhead. The night is cool and '.
|
||||
'the air is crisp. The trees are calm.');
|
||||
} else if ($phase->isWaxing()) {
|
||||
$time = pht(
|
||||
'Night has fallen. The moon overhead is waxing, and provides '.
|
||||
'just enough light that you can make out your surroundings. It '.
|
||||
'is quite cold.');
|
||||
} else if ($phase->isWaning()) {
|
||||
$time = pht(
|
||||
'Night has fallen. The moon overhead is waning. You can barely '.
|
||||
'make out your surroundings. It is very cold.');
|
||||
}
|
||||
}
|
||||
|
||||
echo tsprintf(
|
||||
"%W\n\n",
|
||||
$time);
|
||||
|
||||
echo tsprintf(
|
||||
"%W\n\n",
|
||||
pht(
|
||||
'Several small trails and footpaths cross here, twisting away from '.
|
||||
'you among the trees.'));
|
||||
|
||||
echo tsprintf(
|
||||
pht("Just ahead to the north, you can see **remotes**.\n"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function lookRemotes() {
|
||||
echo tsprintf(
|
||||
"%W\n\n",
|
||||
pht(
|
||||
'You follow a wide, straight path to the north and arrive in a '.
|
||||
'grove of fruit trees after a few minutes of walking. The grass '.
|
||||
'underfoot is thick and small insects flit through the air.'));
|
||||
|
||||
echo tsprintf(
|
||||
"%W\n\n",
|
||||
pht(
|
||||
'At the far edge of the grove, you see remotes:'));
|
||||
|
||||
$api = $this->getRepositoryAPI();
|
||||
|
||||
$remotes = $api->newRemoteRefQuery()
|
||||
->execute();
|
||||
foreach ($remotes as $remote) {
|
||||
|
||||
$view = $remote->newRefView();
|
||||
|
||||
$push_uri = $remote->getPushURI();
|
||||
if ($push_uri === null) {
|
||||
$push_uri = '-';
|
||||
}
|
||||
|
||||
$view->appendLine(
|
||||
pht(
|
||||
'Push URI: %s',
|
||||
$push_uri));
|
||||
|
||||
$fetch_uri = $remote->getFetchURI();
|
||||
if ($fetch_uri === null) {
|
||||
$fetch_uri = '-';
|
||||
}
|
||||
|
||||
$view->appendLine(
|
||||
pht(
|
||||
'Fetch URI: %s',
|
||||
$fetch_uri));
|
||||
|
||||
echo tsprintf('%s', $view);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue