mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 10:12:41 +01:00
Convert arc list
to use PhutilConsoleTable
.
Summary: Similar to D9601 and D9602. Also added pretty colors. Test Plan: {F167702} Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9603
This commit is contained in:
parent
7a99e4bc93
commit
d7541c70dd
1 changed files with 30 additions and 16 deletions
|
@ -39,6 +39,16 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
static $color_map = array(
|
||||||
|
'Closed' => 'cyan',
|
||||||
|
'Needs Review' => 'magenta',
|
||||||
|
'Needs Revision' => 'red',
|
||||||
|
'Changes Planned' => 'red',
|
||||||
|
'Accepted' => 'green',
|
||||||
|
'No Revision' => 'blue',
|
||||||
|
'Abandoned' => 'default',
|
||||||
|
);
|
||||||
|
|
||||||
$revisions = $this->getConduit()->callMethodSynchronous(
|
$revisions = $this->getConduit()->callMethodSynchronous(
|
||||||
'differential.query',
|
'differential.query',
|
||||||
array(
|
array(
|
||||||
|
@ -54,40 +64,44 @@ EOTEXT
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
|
|
||||||
$info = array();
|
$info = array();
|
||||||
|
|
||||||
$status_len = 0;
|
|
||||||
foreach ($revisions as $key => $revision) {
|
foreach ($revisions as $key => $revision) {
|
||||||
$revision_path = Filesystem::resolvePath($revision['sourcePath']);
|
$revision_path = Filesystem::resolvePath($revision['sourcePath']);
|
||||||
$current_path = Filesystem::resolvePath($repository_api->getPath());
|
$current_path = Filesystem::resolvePath($repository_api->getPath());
|
||||||
if ($revision_path == $current_path) {
|
if ($revision_path == $current_path) {
|
||||||
$info[$key]['here'] = 1;
|
$info[$key]['exists'] = 1;
|
||||||
} else {
|
} else {
|
||||||
$info[$key]['here'] = 0;
|
$info[$key]['exists'] = 0;
|
||||||
}
|
}
|
||||||
$info[$key]['sort'] = sprintf(
|
$info[$key]['sort'] = sprintf(
|
||||||
'%d%04d%08d',
|
'%d%04d%08d',
|
||||||
$info[$key]['here'],
|
$info[$key]['exists'],
|
||||||
$revision['status'],
|
$revision['status'],
|
||||||
$revision['id']);
|
$revision['id']);
|
||||||
$info[$key]['statusName'] = $revision['statusName'];
|
$info[$key]['statusName'] = $revision['statusName'];
|
||||||
$status_len = max(
|
$info[$key]['color'] = idx(
|
||||||
$status_len,
|
$color_map, $revision['statusName'], 'default');
|
||||||
strlen($info[$key]['statusName']));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table = id(new PhutilConsoleTable())
|
||||||
|
->setShowHeader(false)
|
||||||
|
->addColumn('exists', array('title' => ''))
|
||||||
|
->addColumn('status', array('title' => 'Status'))
|
||||||
|
->addColumn('title', array('title' => 'Title'));
|
||||||
|
|
||||||
$info = isort($info, 'sort');
|
$info = isort($info, 'sort');
|
||||||
foreach ($info as $key => $spec) {
|
foreach ($info as $key => $spec) {
|
||||||
$revision = $revisions[$key];
|
$revision = $revisions[$key];
|
||||||
printf(
|
|
||||||
"%s %-".($status_len + 4)."s D%d: %s\n",
|
$table->addRow(array(
|
||||||
$spec['here']
|
'exists' => $spec['exists'] ? phutil_console_format('**%s**', '*') : '',
|
||||||
? phutil_console_format('**%s**', '*')
|
'status' => phutil_console_format(
|
||||||
: ' ',
|
"<fg:{$spec['color']}>%s</fg>", $spec['statusName']),
|
||||||
$spec['statusName'],
|
'title' => phutil_console_format(
|
||||||
$revision['id'],
|
'**D%d:** %s', $revision['id'], $revision['title']),
|
||||||
$revision['title']);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table->draw();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue