From d68bd4b77a871049be7554cfe754b1ed3bc67104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 25 Mar 2019 14:15:33 +0200 Subject: [PATCH] render links in terminal --- src/Command/WeeklyReportCommand.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Command/WeeklyReportCommand.php b/src/Command/WeeklyReportCommand.php index 406d611..49023e0 100644 --- a/src/Command/WeeklyReportCommand.php +++ b/src/Command/WeeklyReportCommand.php @@ -97,13 +97,31 @@ private function formatIssuesTable(array $issues) $table->setColumnStyle(0, $rightAligned); $table->setHeaders(array('issue id', 'issue summary')); + $issueWidth = 0; foreach ($issues as $type => $issue) { - $table->addRow(array($issue['iss_id'], $issue['iss_summary'])); + $issueId = $this->renderIssueLink($issue['iss_id']); + $table->addRow(array($issueId, $issue['iss_summary'])); } + $table->setColumnWidth(0, 10); + + $table->setColumnWidths(array(10, 0, 30)); $table->render(); } + /** + * @see https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence + * @see https://github.com/symfony/symfony/pull/29668 + * @see https://github.com/symfony/console/commit/20e4894521056ff6aa059015143bb971d475469a#diff-5871b25b12684413fc82089739d41411 symfony 4.2+ + * @see https://github.com/symfony/console/commit/4f04cf84d6b0ce4beae6d1ed7767043636d7bfab#diff-5871b25b12684413fc82089739d41411 4.3.0 + * @see https://youtrack.jetbrains.com/issue/IDEA-204536 + */ + private function renderIssueLink($issue_id, $issue_link1 = '') + { + $issue_link = 'http://example.com'; + return "\e]8;;{$issue_link}\e\\{$issue_id}\e]8;;\e\\"; + } + private function formatIssueStatuses(array $data) { $this->output->writeln('Issues by status:');