Page MenuHomePhorge

No OneTemporary

diff --git a/src/workflow/ArcanistPhrequentWorkflow.php b/src/workflow/ArcanistPhrequentWorkflow.php
index 852cf9bc..fd6202c4 100644
--- a/src/workflow/ArcanistPhrequentWorkflow.php
+++ b/src/workflow/ArcanistPhrequentWorkflow.php
@@ -1,72 +1,70 @@
<?php
/**
- * Base workflow for Phrequent workflows
+ * Base workflow for Phrequent workflows.
*/
abstract class ArcanistPhrequentWorkflow extends ArcanistWorkflow {
protected function printCurrentTracking() {
$conduit = $this->getConduit();
$results = $conduit->callMethodSynchronous(
'phrequent.tracking',
- array(
- ));
+ array());
$results = $results['data'];
if (count($results) === 0) {
echo phutil_console_format(
- "Not currently tracking time against any object\n");
-
+ "%s\n",
+ pht('Not currently tracking time against any object.'));
return 0;
}
$phids_to_lookup = array();
foreach ($results as $result) {
$phids_to_lookup[] = $result['phid'];
}
$phid_query = $conduit->callMethodSynchronous(
'phid.query',
array(
'phids' => $phids_to_lookup,
));
$phid_map = array();
foreach ($phids_to_lookup as $lookup) {
if (array_key_exists($lookup, $phid_query)) {
$phid_map[$lookup] = $phid_query[$lookup]['fullName'];
} else {
- $phid_map[$lookup] = 'Unknown Object';
+ $phid_map[$lookup] = pht('Unknown Object');
}
}
$table = id(new PhutilConsoleTable())
- ->addColumn('type', array('title' => 'Status'))
- ->addColumn('time', array('title' => 'Tracked', 'align' => 'right'))
- ->addColumn('name', array('title' => 'Name'))
+ ->addColumn('type', array('title' => pht('Status')))
+ ->addColumn('time', array('title' => pht('Tracked'), 'align' => 'right'))
+ ->addColumn('name', array('title' => pht('Name')))
->setBorders(false);
$i = 0;
foreach ($results as $result) {
if ($i === 0) {
- $column_type = 'In Progress';
+ $column_type = pht('In Progress');
} else {
- $column_type = 'Suspended';
+ $column_type = pht('Suspended');
}
$table->addRow(array(
'type' => '('.$column_type.')',
'time' => phutil_format_relative_time($result['time']),
'name' => $phid_map[$result['phid']],
));
$i++;
}
$table->draw();
-
return 0;
}
}
diff --git a/src/workflow/ArcanistStartWorkflow.php b/src/workflow/ArcanistStartWorkflow.php
index 483f334c..b940265e 100644
--- a/src/workflow/ArcanistStartWorkflow.php
+++ b/src/workflow/ArcanistStartWorkflow.php
@@ -1,92 +1,82 @@
<?php
/**
- * Start time tracking on an object
+ * Start time tracking on an object.
*/
final class ArcanistStartWorkflow extends ArcanistPhrequentWorkflow {
public function getWorkflowName() {
return 'start';
}
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**start** __object__
EOTEXT
);
}
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
-Start tracking work in Phrequent.
+ Start tracking work in Phrequent.
EOTEXT
);
}
public function requiresConduit() {
return true;
}
- public function desiresWorkingCopy() {
- return false;
- }
-
public function requiresAuthentication() {
return true;
}
public function getArguments() {
return array(
'*' => 'name',
);
}
public function run() {
$conduit = $this->getConduit();
$started_phids = array();
$short_name = $this->getArgument('name');
+
foreach ($short_name as $object_name) {
$object_lookup = $conduit->callMethodSynchronous(
'phid.lookup',
array(
'names' => array($object_name),
));
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;
}
$object_phid = $object_lookup[$object_name]['phid'];
$started_phids[] = $conduit->callMethodSynchronous(
'phrequent.push',
array(
'objectPHID' => $object_phid,
));
}
$phid_query = $conduit->callMethodSynchronous(
'phid.query',
array(
'phids' => $started_phids,
));
- $name = '';
- foreach ($phid_query as $ref) {
- if ($name === '') {
- $name = $ref['fullName'];
- } else {
- $name .= ', '.$ref['fullName'];
- }
- }
-
echo phutil_console_format(
- "Started: %s\n\n",
- $name);
-
+ "%s: %s\n\n",
+ pht('Started'),
+ implode(', ', ipull($phid_query, 'fullName')));
$this->printCurrentTracking(true);
}
}
diff --git a/src/workflow/ArcanistStopWorkflow.php b/src/workflow/ArcanistStopWorkflow.php
index ad0ee847..f9820f4e 100644
--- a/src/workflow/ArcanistStopWorkflow.php
+++ b/src/workflow/ArcanistStopWorkflow.php
@@ -1,132 +1,111 @@
<?php
/**
- * Stop time tracking on an object
+ * Stop time tracking on an object.
*/
final class ArcanistStopWorkflow extends ArcanistPhrequentWorkflow {
public function getWorkflowName() {
return 'stop';
}
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**stop** [--note __note__] [__objects__]
EOTEXT
);
}
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
-Start tracking work in Phrequent.
+ Start tracking work in Phrequent.
EOTEXT
);
}
public function requiresConduit() {
return true;
}
- public function desiresWorkingCopy() {
- return false;
- }
-
public function requiresAuthentication() {
return true;
}
public function getArguments() {
return array(
'note' => array(
'param' => 'note',
- 'help' =>
- 'A note to attach to the tracked time.',
+ 'help' => pht('A note to attach to the tracked time.'),
),
'*' => 'name',
);
}
public function run() {
$conduit = $this->getConduit();
-
$names = $this->getArgument('name');
$object_lookup = $conduit->callMethodSynchronous(
'phid.lookup',
array(
'names' => $names,
));
foreach ($names as $object_name) {
if (!array_key_exists($object_name, $object_lookup)) {
throw new ArcanistUsageException(
- "No such object '".$object_name."' found.");
+ pht("No such object '%s' found.", $object_name));
return 1;
}
}
if (count($names) === 0) {
// 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);
}
$stopped_phids = array();
foreach ($object_lookup as $ref) {
$object_phid = $ref['phid'];
$stopped_phid = $conduit->callMethodSynchronous(
'phrequent.pop',
array(
'objectPHID' => $object_phid,
'note' => $this->getArgument('note'),
));
if ($stopped_phid !== null) {
$stopped_phids[] = $stopped_phid;
}
}
if (count($stopped_phids) === 0) {
if (count($names) === 0) {
echo phutil_console_format(
- "Not currently tracking time against any object\n");
+ "%s\n",
+ pht('Not currently tracking time against any object.'));
} else {
- $name = '';
- foreach ($object_lookup as $ref) {
- if ($name === '') {
- $name = $ref['fullName'];
- } else {
- $name = ', '.$ref['fullName'];
- }
- }
-
echo phutil_console_format(
- "Not currently tracking time against %s\n",
- $name);
+ "%s\n",
+ pht(
+ 'Not currently tracking time against %s.',
+ implode(', ', ipull($object_lookup, 'fullName'))));
}
return 1;
}
$phid_query = $conduit->callMethodSynchronous(
'phid.query',
array(
'phids' => $stopped_phids,
));
- $name = '';
- foreach ($phid_query as $ref) {
- if ($name === '') {
- $name = $ref['fullName'];
- } else {
- $name .= ', '.$ref['fullName'];
- }
- }
-
echo phutil_console_format(
- "Stopped: %s\n\n",
- $name);
-
+ "%s %s\n\n",
+ pht('Stopped:'),
+ implode(', ', ipull($phid_query, 'fullName')));
$this->printCurrentTracking(true);
}
}
diff --git a/src/workflow/ArcanistTimeWorkflow.php b/src/workflow/ArcanistTimeWorkflow.php
index 858f60c4..0080582a 100644
--- a/src/workflow/ArcanistTimeWorkflow.php
+++ b/src/workflow/ArcanistTimeWorkflow.php
@@ -1,47 +1,38 @@
<?php
/**
- * Show time being tracked in Phrequent
+ * Show time being tracked in Phrequent.
*/
final class ArcanistTimeWorkflow extends ArcanistPhrequentWorkflow {
public function getWorkflowName() {
return 'time';
}
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**time**
EOTEXT
);
}
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
-Show what you're currently tracking in Phrequent.
+ Show what you're currently tracking in Phrequent.
EOTEXT
);
}
public function requiresConduit() {
return true;
}
- public function desiresWorkingCopy() {
- return false;
- }
-
public function requiresAuthentication() {
return true;
}
- public function getArguments() {
- return array(
- );
- }
-
public function run() {
$this->printCurrentTracking();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 15:30 (3 w, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126013
Default Alt Text
(9 KB)

Event Timeline