mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Convert arc feature
to use PhutilConsoleTable
.
Summary: Fixes T5110. `PhutilConsoleTable` handles Unicode characters and can display a decent-looking table. Test Plan: {F167698} Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5110 Differential Revision: https://secure.phabricator.com/D9602
This commit is contained in:
parent
9f8a23d598
commit
7a99e4bc93
1 changed files with 20 additions and 22 deletions
|
@ -51,7 +51,6 @@ EOTEXT
|
||||||
return !$this->getArgument('branch');
|
return !$this->getArgument('branch');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getArguments() {
|
public function getArguments() {
|
||||||
return array(
|
return array(
|
||||||
'view-all' => array(
|
'view-all' => array(
|
||||||
|
@ -63,7 +62,7 @@ EOTEXT
|
||||||
'output' => array(
|
'output' => array(
|
||||||
'param' => 'format',
|
'param' => 'format',
|
||||||
'support' => array(
|
'support' => array(
|
||||||
'json'
|
'json',
|
||||||
),
|
),
|
||||||
'help' => "With 'json', show features in machine-readable JSON format.",
|
'help' => "With 'json', show features in machine-readable JSON format.",
|
||||||
),
|
),
|
||||||
|
@ -93,9 +92,7 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
$branches = $this->loadCommitInfo($branches);
|
$branches = $this->loadCommitInfo($branches);
|
||||||
|
|
||||||
$revisions = $this->loadRevisions($branches);
|
$revisions = $this->loadRevisions($branches);
|
||||||
|
|
||||||
$this->printBranches($branches, $revisions);
|
$this->printBranches($branches, $revisions);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -116,15 +113,12 @@ EOTEXT
|
||||||
if (isset($names[1])) {
|
if (isset($names[1])) {
|
||||||
$start = $names[1];
|
$start = $names[1];
|
||||||
} else {
|
} else {
|
||||||
$start = $this->getConfigFromAnySource(
|
$start = $this->getConfigFromAnySource('arc.feature.start.default');
|
||||||
'arc.feature.start.default');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$branches = $api->getAllBranches();
|
$branches = $api->getAllBranches();
|
||||||
if (in_array($name, ipull($branches, 'name'))) {
|
if (in_array($name, ipull($branches, 'name'))) {
|
||||||
list($err, $stdout, $stderr) = $api->execManualLocal(
|
list($err, $stdout, $stderr) = $api->execManualLocal($command, $name);
|
||||||
$command,
|
|
||||||
$name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
|
@ -155,10 +149,7 @@ EOTEXT
|
||||||
$rev = csprintf('-r %s', $start);
|
$rev = csprintf('-r %s', $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
$exec = $api->execManualLocal(
|
$exec = $api->execManualLocal('bookmark %C %s', $rev, $name);
|
||||||
'bookmark %C %s',
|
|
||||||
$rev,
|
|
||||||
$name);
|
|
||||||
|
|
||||||
if (!$exec[0] && $start) {
|
if (!$exec[0] && $start) {
|
||||||
$api->execxLocal('update %s', $name);
|
$api->execxLocal('update %s', $name);
|
||||||
|
@ -189,7 +180,6 @@ EOTEXT
|
||||||
'log -l 1 --template %s -r %s',
|
'log -l 1 --template %s -r %s',
|
||||||
"{node}\1{date|hgdate}\1{p1node}\1{desc|firstline}\1{desc}",
|
"{node}\1{date|hgdate}\1{p1node}\1{desc|firstline}\1{desc}",
|
||||||
hgsprintf('%s', $branch['name']));
|
hgsprintf('%s', $branch['name']));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// NOTE: "-s" is an option deep in git's diff argument parser that
|
// NOTE: "-s" is an option deep in git's diff argument parser that
|
||||||
// doesn't seem to have much documentation and has no long form. It
|
// doesn't seem to have much documentation and has no long form. It
|
||||||
|
@ -353,16 +343,24 @@ EOTEXT
|
||||||
}
|
}
|
||||||
echo json_encode(ipull($out, null, 'name'))."\n";
|
echo json_encode(ipull($out, null, 'name'))."\n";
|
||||||
} else {
|
} else {
|
||||||
$console = PhutilConsole::getConsole();
|
$table = id(new PhutilConsoleTable())
|
||||||
|
->setShowHeader(false)
|
||||||
|
->addColumn('current', array('title' => ''))
|
||||||
|
->addColumn('name', array('title' => 'Name'))
|
||||||
|
->addColumn('status', array('title' => 'Status'))
|
||||||
|
->addColumn('descr', array('title' => 'Description'));
|
||||||
|
|
||||||
foreach ($out as $line) {
|
foreach ($out as $line) {
|
||||||
$color = $line['color'];
|
$table->addRow(array(
|
||||||
$console->writeOut(
|
'current' => $line['current'] ? '*' : '',
|
||||||
"%s **%s** <fg:{$color}>%s</fg> %s\n",
|
'name' => phutil_console_format('**%s**', $line['name']),
|
||||||
$line['current'] ? '* ' : ' ',
|
'status' => phutil_console_format(
|
||||||
str_pad($line['name'], $len_name),
|
"<fg:{$line['color']}>%s</fg>", $line['status']),
|
||||||
str_pad($line['status'], $len_status),
|
'descr' => $line['desc'],
|
||||||
$line['desc']);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table->draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue