mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Port "arc weld" and "arc anoid" to Toolsets workflows, plus minor fixes
Summary: Ref T13490. Update the "weld" workflow and the "anoid" workflow. Incorporates D20938. Test Plan: Ran "arc weld". Ran "arc anoid". Maniphest Tasks: T13490 Differential Revision: https://secure.phabricator.com/D21001
This commit is contained in:
parent
8cd79d38af
commit
db8419f19b
11 changed files with 88 additions and 50 deletions
|
@ -966,7 +966,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistAliasWorkflow' => 'ArcanistWorkflow',
|
'ArcanistAliasWorkflow' => 'ArcanistWorkflow',
|
||||||
'ArcanistAliasesConfigOption' => 'ArcanistListConfigOption',
|
'ArcanistAliasesConfigOption' => 'ArcanistListConfigOption',
|
||||||
'ArcanistAmendWorkflow' => 'ArcanistWorkflow',
|
'ArcanistAmendWorkflow' => 'ArcanistWorkflow',
|
||||||
'ArcanistAnoidWorkflow' => 'ArcanistWorkflow',
|
'ArcanistAnoidWorkflow' => 'ArcanistArcWorkflow',
|
||||||
'ArcanistArcConfigurationEngineExtension' => 'ArcanistConfigurationEngineExtension',
|
'ArcanistArcConfigurationEngineExtension' => 'ArcanistConfigurationEngineExtension',
|
||||||
'ArcanistArcToolset' => 'ArcanistToolset',
|
'ArcanistArcToolset' => 'ArcanistToolset',
|
||||||
'ArcanistArcWorkflow' => 'ArcanistWorkflow',
|
'ArcanistArcWorkflow' => 'ArcanistWorkflow',
|
||||||
|
@ -1410,7 +1410,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistVariableVariableXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
'ArcanistVariableVariableXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||||
'ArcanistVariableVariableXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
'ArcanistVariableVariableXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||||
'ArcanistVersionWorkflow' => 'ArcanistWorkflow',
|
'ArcanistVersionWorkflow' => 'ArcanistWorkflow',
|
||||||
'ArcanistWeldWorkflow' => 'ArcanistWorkflow',
|
'ArcanistWeldWorkflow' => 'ArcanistArcWorkflow',
|
||||||
'ArcanistWhichWorkflow' => 'ArcanistWorkflow',
|
'ArcanistWhichWorkflow' => 'ArcanistWorkflow',
|
||||||
'ArcanistWildConfigOption' => 'ArcanistConfigOption',
|
'ArcanistWildConfigOption' => 'ArcanistConfigOption',
|
||||||
'ArcanistWorkflow' => 'Phobject',
|
'ArcanistWorkflow' => 'Phobject',
|
||||||
|
|
|
@ -139,11 +139,14 @@ final class ArcanistRuntime {
|
||||||
try {
|
try {
|
||||||
return $args->parseWorkflowsFull($phutil_workflows);
|
return $args->parseWorkflowsFull($phutil_workflows);
|
||||||
} catch (PhutilArgumentUsageException $usage_exception) {
|
} catch (PhutilArgumentUsageException $usage_exception) {
|
||||||
$log->writeHint(
|
|
||||||
pht('(::)'),
|
// TODO: This is very, very hacky; we're trying to let errors like
|
||||||
pht(
|
// "you passed the wrong arguments" through but fall back to classic
|
||||||
'Workflow is unrecognized by modern "arc", falling through '.
|
// mode if the workflow itself doesn't exist.
|
||||||
'to classic mode.'));
|
if (!preg_match('/invalid command/i', $usage_exception->getMessage())) {
|
||||||
|
throw $usage_exception;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$arcanist_root = phutil_get_library_root('arcanist');
|
$arcanist_root = phutil_get_library_root('arcanist');
|
||||||
|
|
|
@ -4,6 +4,7 @@ final class ArcanistWorkflowInformation
|
||||||
extends Phobject {
|
extends Phobject {
|
||||||
|
|
||||||
private $help;
|
private $help;
|
||||||
|
private $synopsis;
|
||||||
private $examples = array();
|
private $examples = array();
|
||||||
|
|
||||||
public function setHelp($help) {
|
public function setHelp($help) {
|
||||||
|
@ -24,4 +25,13 @@ final class ArcanistWorkflowInformation
|
||||||
return $this->examples;
|
return $this->examples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSynopsis($synopsis) {
|
||||||
|
$this->synopsis = $synopsis;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSynopsis() {
|
||||||
|
return $this->synopsis;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,10 @@ EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->newWorkflowInformation()
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(
|
||||||
|
pht('Create and modify command aliases.'))
|
||||||
->addExample(pht('**alias**'))
|
->addExample(pht('**alias**'))
|
||||||
->addExample(pht('**alias** __command__'))
|
->addExample(pht('**alias** __command__ __target__ -- [__arguments__]'))
|
||||||
->addExample(pht('**alias** __command__ __target__ -- [__options__]'))
|
|
||||||
->setHelp($help);
|
->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->newWorkflowInformation()
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(pht('Install shell completion.'))
|
||||||
->setHelp($help);
|
->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->newWorkflowInformation()
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(pht('Show toolset version information.'))
|
||||||
->addExample(pht('**version**'))
|
->addExample(pht('**version**'))
|
||||||
->setHelp($help);
|
->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,43 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class ArcanistAnoidWorkflow extends ArcanistWorkflow {
|
final class ArcanistAnoidWorkflow
|
||||||
|
extends ArcanistArcWorkflow {
|
||||||
|
|
||||||
public function getWorkflowName() {
|
public function getWorkflowName() {
|
||||||
return 'anoid';
|
return 'anoid';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandSynopses() {
|
public function getWorkflowInformation() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
$help = pht(<<<EOTEXT
|
||||||
**anoid**
|
Take control of a probe launched from the science vessel "Arcanoid".
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(pht('Pilot a probe from the vessel "Arcanoid".'))
|
||||||
|
->addExample(pht('**anoid**'))
|
||||||
|
->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getWorkflowArguments() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return array();
|
||||||
There's only one way to find out...
|
|
||||||
EOTEXT
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function runWorkflow() {
|
||||||
phutil_passthru(
|
if (!Filesystem::binaryExists('python3')) {
|
||||||
'%s/scripts/breakout.py',
|
throw new PhutilArgumentUsageException(
|
||||||
dirname(phutil_get_library_root('arcanist')));
|
pht(
|
||||||
|
'The "arc anoid" workflow requires "python3" to be available '.
|
||||||
|
'in your $PATH.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$support_dir = phutil_get_library_root('arcanist');
|
||||||
|
$support_dir = dirname($support_dir);
|
||||||
|
$support_dir = $support_dir.'/support/';
|
||||||
|
|
||||||
|
$bin = $support_dir.'arcanoid/arcanoid.py';
|
||||||
|
|
||||||
|
return phutil_passthru('%R', $bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->newWorkflowInformation()
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(
|
||||||
|
pht('Create or update an Arcanist library.'))
|
||||||
->addExample(pht('**liberate**'))
|
->addExample(pht('**liberate**'))
|
||||||
->addExample(pht('**liberate** [__path__]'))
|
->addExample(pht('**liberate** [__path__]'))
|
||||||
->setHelp($help);
|
->setHelp($help);
|
||||||
|
|
|
@ -1,36 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class ArcanistWeldWorkflow extends ArcanistWorkflow {
|
final class ArcanistWeldWorkflow
|
||||||
|
extends ArcanistArcWorkflow {
|
||||||
|
|
||||||
public function getWorkflowName() {
|
public function getWorkflowName() {
|
||||||
return 'weld';
|
return 'weld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandSynopses() {
|
public function getWorkflowInformation() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
$help = pht(<<<EOTEXT
|
||||||
**weld** [options] __file__ __file__ ...
|
Robustly fuse two or more files together. The resulting joint is much stronger
|
||||||
|
than the one created by tools like __cat__.
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $this->newWorkflowInformation()
|
||||||
|
->setSynopsis(pht('Robustly fuse files together.'))
|
||||||
|
->addExample('**weld** [options] -- __file__ __file__ ...')
|
||||||
|
->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getWorkflowArguments() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
|
||||||
Robustly fuse two or more files together. The resulting joint is
|
|
||||||
much stronger than the one created by tools like __cat__.
|
|
||||||
EOTEXT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getArguments() {
|
|
||||||
return array(
|
return array(
|
||||||
'*' => 'files',
|
$this->newWorkflowArgument('files')
|
||||||
|
->setWildcard(true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function runWorkflow() {
|
||||||
$files = $this->getArgument('files');
|
$files = $this->getArgument('files');
|
||||||
|
|
||||||
if (count($files) < 2) {
|
if (count($files) < 2) {
|
||||||
throw new ArcanistUsageException(
|
throw new PhutilArgumentUsageException(
|
||||||
pht('Specify two or more files to weld together.'));
|
pht('Specify two or more files to weld together.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,10 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
|
|
||||||
$information = $this->getWorkflowInformation();
|
$information = $this->getWorkflowInformation();
|
||||||
if ($information) {
|
if ($information) {
|
||||||
|
$synopsis = $information->getSynopsis();
|
||||||
|
if (strlen($synopsis)) {
|
||||||
|
$phutil_workflow->setSynopsis($synopsis);
|
||||||
|
}
|
||||||
|
|
||||||
$examples = $information->getExamples();
|
$examples = $information->getExamples();
|
||||||
if ($examples) {
|
if ($examples) {
|
||||||
|
@ -142,7 +146,6 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
|
|
||||||
$phutil_workflow->setHelp($help);
|
$phutil_workflow->setHelp($help);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $phutil_workflow;
|
return $phutil_workflow;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import select
|
import select
|
||||||
|
@ -17,10 +17,10 @@ class Block:
|
||||||
total = 0
|
total = 0
|
||||||
|
|
||||||
def __init__(self, x, y, w, h, c):
|
def __init__(self, x, y, w, h, c):
|
||||||
self.x = x
|
self.x = int(round(x))
|
||||||
self.y = y
|
self.y = int(round(y))
|
||||||
self.w = w
|
self.w = int(round(w))
|
||||||
self.h = h
|
self.h = int(round(h))
|
||||||
self.fmt = curses.A_BOLD | curses.color_pair(c)
|
self.fmt = curses.A_BOLD | curses.color_pair(c)
|
||||||
self.alive = True
|
self.alive = True
|
||||||
for i in range(self.x, self.x + self.w):
|
for i in range(self.x, self.x + self.w):
|
||||||
|
@ -48,8 +48,8 @@ class Ball:
|
||||||
killed = 0
|
killed = 0
|
||||||
|
|
||||||
def __init__(self, x, y, vx, vy):
|
def __init__(self, x, y, vx, vy):
|
||||||
self.x = x
|
self.x = int(round(x))
|
||||||
self.y = y
|
self.y = int(round(y))
|
||||||
self.vx = vx
|
self.vx = vx
|
||||||
self.vy = vy
|
self.vy = vy
|
||||||
Ball.alive = True
|
Ball.alive = True
|
||||||
|
@ -58,6 +58,8 @@ class Ball:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def encounter(self, dx, dy):
|
def encounter(self, dx, dy):
|
||||||
|
dx = int(round(dx))
|
||||||
|
dy = int(round(dy))
|
||||||
ent = grid[self.y + dy + 1][self.x + dx + 1]
|
ent = grid[self.y + dy + 1][self.x + dx + 1]
|
||||||
if ent and not ent.collide(self):
|
if ent and not ent.collide(self):
|
||||||
self.vx -= 2 * dx
|
self.vx -= 2 * dx
|
||||||
|
@ -84,8 +86,8 @@ class Ball:
|
||||||
|
|
||||||
class Ship:
|
class Ship:
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
self.x = x
|
self.x = int(round(x))
|
||||||
self.y = y
|
self.y = int(round(y))
|
||||||
self.hw = 10
|
self.hw = 10
|
||||||
self.v = 4
|
self.v = 4
|
||||||
self.last = 1
|
self.last = 1
|
||||||
|
@ -164,7 +166,7 @@ def main(stdscr):
|
||||||
|
|
||||||
colors = [ 1, 3, 2, 6, 4, 5 ]
|
colors = [ 1, 3, 2, 6, 4, 5 ]
|
||||||
h = height / 10
|
h = height / 10
|
||||||
for x in range(1, width / 7 - 1):
|
for x in range(1, int(width / 7) - 1):
|
||||||
for y in range(1, 7):
|
for y in range(1, 7):
|
||||||
entities.append(Block(x * 7,
|
entities.append(Block(x * 7,
|
||||||
y * h + x / 2 % 2,
|
y * h + x / 2 % 2,
|
Loading…
Reference in a new issue