mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42:40 +01:00
Minor tidying of ArcanistPhrequentWorkflow
classes
Summary: Self-explanatory. Test Plan: Eyeball it. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11555
This commit is contained in:
parent
62e15dcc15
commit
3e63402fef
4 changed files with 35 additions and 77 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base workflow for Phrequent workflows
|
* Base workflow for Phrequent workflows.
|
||||||
*/
|
*/
|
||||||
abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
|
abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
|
||||||
|
|
||||||
|
@ -10,14 +10,13 @@ abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
|
||||||
|
|
||||||
$results = $conduit->callMethodSynchronous(
|
$results = $conduit->callMethodSynchronous(
|
||||||
'phrequent.tracking',
|
'phrequent.tracking',
|
||||||
array(
|
array());
|
||||||
));
|
|
||||||
$results = $results['data'];
|
$results = $results['data'];
|
||||||
|
|
||||||
if (count($results) === 0) {
|
if (count($results) === 0) {
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"Not currently tracking time against any object\n");
|
"%s\n",
|
||||||
|
pht('Not currently tracking time against any object.'));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,22 +36,22 @@ abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
|
||||||
if (array_key_exists($lookup, $phid_query)) {
|
if (array_key_exists($lookup, $phid_query)) {
|
||||||
$phid_map[$lookup] = $phid_query[$lookup]['fullName'];
|
$phid_map[$lookup] = $phid_query[$lookup]['fullName'];
|
||||||
} else {
|
} else {
|
||||||
$phid_map[$lookup] = 'Unknown Object';
|
$phid_map[$lookup] = pht('Unknown Object');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = id(new PhutilConsoleTable())
|
$table = id(new PhutilConsoleTable())
|
||||||
->addColumn('type', array('title' => 'Status'))
|
->addColumn('type', array('title' => pht('Status')))
|
||||||
->addColumn('time', array('title' => 'Tracked', 'align' => 'right'))
|
->addColumn('time', array('title' => pht('Tracked'), 'align' => 'right'))
|
||||||
->addColumn('name', array('title' => 'Name'))
|
->addColumn('name', array('title' => pht('Name')))
|
||||||
->setBorders(false);
|
->setBorders(false);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
if ($i === 0) {
|
if ($i === 0) {
|
||||||
$column_type = 'In Progress';
|
$column_type = pht('In Progress');
|
||||||
} else {
|
} else {
|
||||||
$column_type = 'Suspended';
|
$column_type = pht('Suspended');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->addRow(array(
|
$table->addRow(array(
|
||||||
|
@ -65,7 +64,6 @@ abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->draw();
|
$table->draw();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start time tracking on an object
|
* Start time tracking on an object.
|
||||||
*/
|
*/
|
||||||
final class ArcanistStartWorkflow extends ArcanistPhrequentWorkflow {
|
final class ArcanistStartWorkflow extends ArcanistPhrequentWorkflow {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ EOTEXT
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getCommandHelp() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
Start tracking work in Phrequent.
|
Start tracking work in Phrequent.
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ EOTEXT
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function desiresWorkingCopy() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function requiresAuthentication() {
|
public function requiresAuthentication() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +42,7 @@ EOTEXT
|
||||||
|
|
||||||
$started_phids = array();
|
$started_phids = array();
|
||||||
$short_name = $this->getArgument('name');
|
$short_name = $this->getArgument('name');
|
||||||
|
|
||||||
foreach ($short_name as $object_name) {
|
foreach ($short_name as $object_name) {
|
||||||
$object_lookup = $conduit->callMethodSynchronous(
|
$object_lookup = $conduit->callMethodSynchronous(
|
||||||
'phid.lookup',
|
'phid.lookup',
|
||||||
|
@ -54,7 +51,9 @@ EOTEXT
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!array_key_exists($object_name, $object_lookup)) {
|
if (!array_key_exists($object_name, $object_lookup)) {
|
||||||
echo "No such object '".$object_name."' found.\n";
|
echo phutil_console_format(
|
||||||
|
"%s\n",
|
||||||
|
pht("No such object '%s' found.", $object_name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,19 +72,10 @@ EOTEXT
|
||||||
'phids' => $started_phids,
|
'phids' => $started_phids,
|
||||||
));
|
));
|
||||||
|
|
||||||
$name = '';
|
|
||||||
foreach ($phid_query as $ref) {
|
|
||||||
if ($name === '') {
|
|
||||||
$name = $ref['fullName'];
|
|
||||||
} else {
|
|
||||||
$name .= ', '.$ref['fullName'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"Started: %s\n\n",
|
"%s: %s\n\n",
|
||||||
$name);
|
pht('Started'),
|
||||||
|
implode(', ', ipull($phid_query, 'fullName')));
|
||||||
$this->printCurrentTracking(true);
|
$this->printCurrentTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop time tracking on an object
|
* Stop time tracking on an object.
|
||||||
*/
|
*/
|
||||||
final class ArcanistStopWorkflow extends ArcanistPhrequentWorkflow {
|
final class ArcanistStopWorkflow extends ArcanistPhrequentWorkflow {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ EOTEXT
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getCommandHelp() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
Start tracking work in Phrequent.
|
Start tracking work in Phrequent.
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ EOTEXT
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function desiresWorkingCopy() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function requiresAuthentication() {
|
public function requiresAuthentication() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,8 +35,7 @@ EOTEXT
|
||||||
return array(
|
return array(
|
||||||
'note' => array(
|
'note' => array(
|
||||||
'param' => 'note',
|
'param' => 'note',
|
||||||
'help' =>
|
'help' => pht('A note to attach to the tracked time.'),
|
||||||
'A note to attach to the tracked time.',
|
|
||||||
),
|
),
|
||||||
'*' => 'name',
|
'*' => 'name',
|
||||||
);
|
);
|
||||||
|
@ -48,7 +43,6 @@ EOTEXT
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
$conduit = $this->getConduit();
|
$conduit = $this->getConduit();
|
||||||
|
|
||||||
$names = $this->getArgument('name');
|
$names = $this->getArgument('name');
|
||||||
|
|
||||||
$object_lookup = $conduit->callMethodSynchronous(
|
$object_lookup = $conduit->callMethodSynchronous(
|
||||||
|
@ -60,14 +54,14 @@ EOTEXT
|
||||||
foreach ($names as $object_name) {
|
foreach ($names as $object_name) {
|
||||||
if (!array_key_exists($object_name, $object_lookup)) {
|
if (!array_key_exists($object_name, $object_lookup)) {
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
"No such object '".$object_name."' found.");
|
pht("No such object '%s' found.", $object_name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($names) === 0) {
|
if (count($names) === 0) {
|
||||||
// Implicit stop; add an entry so the loop will call
|
// Implicit stop; add an entry so the loop will call
|
||||||
// phrequent.pop with a null objectPHID.
|
// `phrequent.pop` with a null `objectPHID`.
|
||||||
$object_lookup[] = array('phid' => null);
|
$object_lookup[] = array('phid' => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,20 +83,14 @@ EOTEXT
|
||||||
if (count($stopped_phids) === 0) {
|
if (count($stopped_phids) === 0) {
|
||||||
if (count($names) === 0) {
|
if (count($names) === 0) {
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"Not currently tracking time against any object\n");
|
"%s\n",
|
||||||
|
pht('Not currently tracking time against any object.'));
|
||||||
} else {
|
} else {
|
||||||
$name = '';
|
|
||||||
foreach ($object_lookup as $ref) {
|
|
||||||
if ($name === '') {
|
|
||||||
$name = $ref['fullName'];
|
|
||||||
} else {
|
|
||||||
$name = ', '.$ref['fullName'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"Not currently tracking time against %s\n",
|
"%s\n",
|
||||||
$name);
|
pht(
|
||||||
|
'Not currently tracking time against %s.',
|
||||||
|
implode(', ', ipull($object_lookup, 'fullName'))));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -113,19 +101,10 @@ EOTEXT
|
||||||
'phids' => $stopped_phids,
|
'phids' => $stopped_phids,
|
||||||
));
|
));
|
||||||
|
|
||||||
$name = '';
|
|
||||||
foreach ($phid_query as $ref) {
|
|
||||||
if ($name === '') {
|
|
||||||
$name = $ref['fullName'];
|
|
||||||
} else {
|
|
||||||
$name .= ', '.$ref['fullName'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"Stopped: %s\n\n",
|
"%s %s\n\n",
|
||||||
$name);
|
pht('Stopped:'),
|
||||||
|
implode(', ', ipull($phid_query, 'fullName')));
|
||||||
$this->printCurrentTracking(true);
|
$this->printCurrentTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show time being tracked in Phrequent
|
* Show time being tracked in Phrequent.
|
||||||
*/
|
*/
|
||||||
final class ArcanistTimeWorkflow extends ArcanistPhrequentWorkflow {
|
final class ArcanistTimeWorkflow extends ArcanistPhrequentWorkflow {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ EOTEXT
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getCommandHelp() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
Show what you're currently tracking in Phrequent.
|
Show what you're currently tracking in Phrequent.
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -27,19 +27,10 @@ EOTEXT
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function desiresWorkingCopy() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function requiresAuthentication() {
|
public function requiresAuthentication() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArguments() {
|
|
||||||
return array(
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
$this->printCurrentTracking();
|
$this->printCurrentTracking();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue