Skip to content

Commit

Permalink
Adjusted result presentation for the retrieve command
Browse files Browse the repository at this point in the history
  • Loading branch information
bhermann committed Oct 31, 2018
1 parent b8c291a commit a5fb88a
Showing 1 changed file with 40 additions and 13 deletions.
53 changes: 40 additions & 13 deletions src/main/scala/de/upb/cs/swt/delphi/cli/ResultBeautifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,51 @@ object ResultBeautifier {

def beautifyRetrieveResults(results : Seq[RetrieveResult]) : String = {
results.map { r =>
val at = new AsciiTable()

at.addRule()

// add body
for(
(key, value) <- r.metricResults.toList.sortBy(x => x._1)
) {
val ar = at.addRow(Seq(key, value).asJavaCollection)
asScalaBuffer(ar.getCells).tail.foreach { c => c.getContext.setTextAlignment(TextAlignment.RIGHT)}
val basedata = {
val at = new AsciiTable()

at.addRule()

at.addRow("source", r.metadata.source)
at.addRow("artifactId", r.metadata.artifactId)
at.addRow("groupId", r.metadata.groupId)
at.addRow("version", r.metadata.version)
at.addRow("discovered at", r.metadata.discovered)
at.addRule()
at.getRenderer.setCWC(new CWC_LongestLine)
at.setPaddingLeftRight(1)
at.getContext.setFrameLeftMargin(2)
"↳ Basic information" + System.lineSeparator() + at.render() + System.lineSeparator()
}

at.addRule()
val metrics = r.metricResults.size match {
case 0 => ""
case _ => {
val at = new AsciiTable()

at.getRenderer.setCWC(new CWC_LongestLine)
at.setPaddingRight(1)
at.addRule()

// add body
for(
(key, value) <- r.metricResults.toList.sortBy(x => x._1)
) {
val ar = at.addRow(Seq(key, value).asJavaCollection)
asScalaBuffer(ar.getCells).tail.foreach { c => c.getContext.setTextAlignment(TextAlignment.RIGHT)}
}

at.addRule()

at.getRenderer.setCWC(new CWC_LongestLine)
at.setPaddingLeftRight(1)
at.getContext.setFrameLeftMargin(2)
at.getContext.setFrameBottomMargin(1)
"↳ Metrics:" + System.lineSeparator() + at.render()
}
}

System.lineSeparator() + r.toMavenIdentifier() + System.lineSeparator() + basedata + metrics + System.lineSeparator()

System.lineSeparator() + r.toMavenIdentifier() + System.lineSeparator() + at.render()
}.fold("")(_ + _)
}
}

0 comments on commit a5fb88a

Please sign in to comment.