1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Convert more scripts to use PhutilConsoleTable.

Summary: Convert `./bin/mail` and a`./bin/sms` to use `PhutilConsoleTable` for formatting output.

Test Plan: I don't actually have mail and SMS setup on my dev box, but this is a pretty straightforward change.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9621
This commit is contained in:
Joshua Spence 2014-06-19 02:36:58 +10:00
parent e0ca39f6a1
commit 47964077ef
3 changed files with 46 additions and 28 deletions

View file

@ -41,23 +41,29 @@ final class PhabricatorMailManagementListInboundWorkflow
->withPHIDs($phids)
->execute();
$table = id(new PhutilConsoleTable())
->setShowHeader(false)
->addColumn('id', array('title' => 'ID'))
->addColumn('author', array('title' => 'Author'))
->addColumn('phid', array('title' => 'Related PHID'))
->addColumn('subject', array('title' => 'Subject'));
foreach (array_reverse($mails) as $mail) {
$console->writeOut(
"%s\n",
sprintf(
'% 8d %-16s %-20s %s',
$mail->getID(),
$mail->getAuthorPHID()
? $handles[$mail->getAuthorPHID()]->getName()
: '-',
$mail->getRelatedPHID()
? $handles[$mail->getRelatedPHID()]->getName()
: '-',
$mail->getSubject()
? $mail->getSubject()
: pht('(No subject.)')));
$table->addRow(array(
'id' => $mail->getID(),
'author' => $mail->getAuthorPHID()
? $handles[$mail->getAuthorPHID()]->getName()
: '-',
'phid' => $mail->getRelatedPHID()
? $handles[$mail->getRelatedPHID()]->getName()
: '-',
'subject' => $mail->getSubject()
? $mail->getSubject()
: pht('(No subject.)'),
));
}
$table->draw();
return 0;
}

View file

@ -33,16 +33,23 @@ final class PhabricatorMailManagementListOutboundWorkflow
return 0;
}
$table = id(new PhutilConsoleTable())
->setShowHeader(false)
->addColumn('id', array('title' => 'ID'))
->addColumn('status', array('title' => 'Status'))
->addColumn('subject', array('title' => 'Subject'));
foreach (array_reverse($mails) as $mail) {
$console->writeOut(
"%s\n",
sprintf(
'% 8d %-8s %s',
$mail->getID(),
PhabricatorMetaMTAMail::getReadableStatus($mail->getStatus()),
$mail->getSubject()));
$status = $mail->getStatus();
$table->addRow(array(
'id' => $mail->getID(),
'status' => PhabricatorMetaMTAMail::getReadableStatus($status),
'subject' => $mail->getSubject(),
));
}
$table->draw();
return 0;
}

View file

@ -34,16 +34,21 @@ final class PhabricatorSMSManagementListOutboundWorkflow
return 0;
}
$table = id(new PhutilConsoleTable())
->setShowHeader(false)
->addColumn('id', array('title' => 'ID'))
->addColumn('status', array('title' => 'Status'))
->addColumn('recv', array('title' => 'Recipient'));
foreach (array_reverse($sms_messages) as $sms) {
$console->writeOut(
"%s\n",
sprintf(
'% 8d %-8s To: %s',
$sms->getID(),
$sms->getSendStatus(),
$sms->getToNumber()));
$table->addRow(array(
'id' => $sms->getID(),
'status' => $sms->getSendStatus(),
'recv' => $sms->getToNumber(),
));
}
$table->draw();
return 0;
}