Skip to content

Commit 94b1fc0

Browse files
authored
Merge pull request #37 from delphi-hub/release/0.9.5
Release/0.9.5
2 parents 9f7b01c + 518f76a commit 94b1fc0

18 files changed

+502
-247
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: scala
22
scala:
3-
- 2.12.4
3+
- 2.13.1
44
script:
55
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; fi'
6-
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; fi'
6+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; fi'
7+
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; fi'
78
after_success:
8-
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'
9+
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Delphi Command-Line Interface (CLI)
1+
# Delphi Command-Line Interface (CLI) <img src="https://github.com/delphi-hub/delphi/raw/master/img/delphi.png" align="right" height=140/>
22

33
The command-line interface for the Delphi platform.
44

55
We are currently in pre-alpha state! There is no release and the code in
66
this repository is purely experimental!
77

8-
|branch | status | codacy | snyk |
9-
| :---: | :---: | :---: | :---: |
10-
| master | [![Build Status](https://travis-ci.org/delphi-hub/delphi-cli.svg?branch=master)](https://travis-ci.org/delphi-hub/delphi-cli) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/47046de0e8d64ae4b76191b7dae80075)](https://www.codacy.com/app/delphi-hub/delphi-cli?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=delphi-hub/delphi-cli&amp;utm_campaign=Badge_Grade)| [![Known Vulnerabilities](https://snyk.io/test/github/delphi-hub/delphi-cli/badge.svg?targetFile=build.sbt)](https://snyk.io/test/github/delphi-hub/delphi-cli?targetFile=build.sbt) |
11-
| develop | [![Build Status](https://travis-ci.org/delphi-hub/delphi-cli.svg?branch=develop)](https://travis-ci.org/delphi-hub/delphi-cli) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/47046de0e8d64ae4b76191b7dae80075?branch=develop)](https://www.codacy.com/app/delphi-hub/delphi-cli?branch=develop&amp;utm_source=github.com&amp;utm_medium=referral&amp;utm_content=delphi-hub/delphi-cli&amp;utm_campaign=Badge_Grade)| [![Known Vulnerabilities](https://snyk.io/test/github/delphi-hub/delphi-cli/develop/badge.svg?targetFile=build.sbt)](https://snyk.io/test/github/delphi-hub/delphi-cli/develop?targetFile=build.sbt)
8+
|branch | status | codacy | coverage | snyk |
9+
| :---: | :---: | :---: | :---: | :---: |
10+
| master | [![Build Status](https://travis-ci.org/delphi-hub/delphi-cli.svg?branch=master)](https://travis-ci.org/delphi-hub/delphi-cli) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/47046de0e8d64ae4b76191b7dae80075)](https://www.codacy.com/app/delphi-hub/delphi-cli?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=delphi-hub/delphi-cli&amp;utm_campaign=Badge_Grade) | [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/47046de0e8d64ae4b76191b7dae80075)](https://www.codacy.com/manual/delphi-hub/delphi-cli?utm_source=github.com&utm_medium=referral&utm_content=delphi-hub/delphi-cli&utm_campaign=Badge_Coverage) | [![Known Vulnerabilities](https://snyk.io/test/github/delphi-hub/delphi-cli/badge.svg?targetFile=build.sbt)](https://snyk.io/test/github/delphi-hub/delphi-cli?targetFile=build.sbt) |
11+
| develop | [![Build Status](https://travis-ci.org/delphi-hub/delphi-cli.svg?branch=develop)](https://travis-ci.org/delphi-hub/delphi-cli) | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/47046de0e8d64ae4b76191b7dae80075?branch=develop)](https://www.codacy.com/app/delphi-hub/delphi-cli?branch=develop&amp;utm_source=github.com&amp;utm_medium=referral&amp;utm_content=delphi-hub/delphi-cli&amp;utm_campaign=Badge_Grade)| [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/47046de0e8d64ae4b76191b7dae80075)](https://www.codacy.com/manual/delphi-hub/delphi-cli?utm_source=github.com&utm_medium=referral&utm_content=delphi-hub/delphi-cli&utm_campaign=Badge_Coverage) | [![Known Vulnerabilities](https://snyk.io/test/github/delphi-hub/delphi-cli/develop/badge.svg?targetFile=build.sbt)](https://snyk.io/test/github/delphi-hub/delphi-cli/develop?targetFile=build.sbt)
1212

1313
## What is the Delphi Command-Line Interface?
1414

@@ -42,8 +42,8 @@ Our software is available as a binary release on [GitHub](https://github.com/del
4242

4343
```
4444
$ delphi --help
45-
Delphi Command Line Tool (1.0.0-SNAPSHOT)
46-
Usage: delphi [test|retrieve|search] [options] <args>...
45+
Delphi Command Line Tool (0.9.5-SNAPSHOT)
46+
Usage: delphi-cli [test|features|retrieve|search] [options] <args>...
4747
4848
--version Prints the version of the command line tool.
4949
--help Prints this help text.

build.sbt

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,114 @@
1-
scalaVersion := "2.12.4"
1+
import com.typesafe.sbt.packager.docker._
2+
3+
ThisBuild / organization := "de.upb.cs.swt.delphi"
4+
ThisBuild / organizationName := "Delphi Project"
5+
ThisBuild / organizationHomepage := Some(url("https://delphi.cs.uni-paderborn.de/"))
6+
7+
ThisBuild / scmInfo := Some(
8+
ScmInfo(
9+
url("https://github.com/delphi-hub/delphi-cli"),
10+
"scm:[email protected]:delphi-hub/delphi-cli.git"
11+
)
12+
)
13+
14+
ThisBuild / developers := List(
15+
Developer(
16+
id = "bhermann",
17+
name = "Ben Hermann",
18+
email = "[email protected]",
19+
url = url("https://www.thewhitespace.de")
20+
)
21+
)
22+
23+
ThisBuild / description := "The command line client for Delphi"
24+
ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt"))
25+
ThisBuild / homepage := Some(url("https://delphi.cs.uni-paderborn.de/"))
26+
27+
lazy val scala212 = "2.12.10"
28+
lazy val scala213 = "2.13.1"
29+
lazy val supportedScalaVersions = List(scala213)
30+
31+
ThisBuild / scalaVersion := scala213
232

333
name := "delphi"
4-
version := "1.0.0-SNAPSHOT"
34+
version := "0.9.5"
535
maintainer := "Ben Hermann <[email protected]>"
636

7-
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html"))
8-
937
packageSummary := "Windows Package for the Delphi CLI"
1038
packageDescription := """Windows Package for the Delphi CLI"""
1139
wixProductId := "ce07be71-510d-414a-92d4-dff47631848a"
1240
wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424"
1341

1442
scalastyleConfig := baseDirectory.value / "project" / "scalastyle_config.xml"
1543

16-
val akkaVersion = "2.5.14"
17-
val akkaHttpVersion = "10.1.5"
44+
val http4sVersion = "0.21.0-M6"
45+
46+
// Only necessary for SNAPSHOT releases
47+
resolvers += Resolver.sonatypeRepo("snapshots")
1848

1949
libraryDependencies ++= Seq(
20-
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion,
21-
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
22-
"com.typesafe.akka" %% "akka-stream" % akkaVersion
50+
"org.http4s" %% "http4s-dsl" % http4sVersion,
51+
"org.http4s" %% "http4s-blaze-client" % http4sVersion,
52+
"org.http4s" %% "http4s-circe" % http4sVersion
2353
)
2454

25-
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.0"
26-
libraryDependencies += "io.spray" %% "spray-json" % "1.3.3"
55+
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.1"
56+
libraryDependencies += "io.spray" %% "spray-json" % "1.3.5"
2757
libraryDependencies += "de.vandermeer" % "asciitable" % "0.3.2"
28-
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.5"
29-
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
58+
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.7"
59+
libraryDependencies += "au.com.bytecode" % "opencsv" % "2.4"
60+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.0" % "test"
61+
libraryDependencies += "joda-time" % "joda-time" % "2.10.5"
62+
63+
libraryDependencies += "de.upb.cs.swt.delphi" %% "delphi-core" % "0.9.2"
64+
libraryDependencies += "de.upb.cs.swt.delphi" %% "delphi-client" % "0.9.2"
65+
66+
libraryDependencies ++= Seq(
67+
"com.softwaremill.sttp" %% "core" % "1.7.2",
68+
"com.softwaremill.sttp" %% "spray-json" % "1.7.2"
69+
)
70+
3071

3172
debianPackageDependencies := Seq("java8-runtime-headless")
73+
mainClass in Compile := Some("de.upb.cs.swt.delphi.cli.DelphiCLI")
74+
discoveredMainClasses in Compile := Seq()
3275

3376
lazy val cli = (project in file(".")).
3477
enablePlugins(JavaAppPackaging).
3578
enablePlugins(DockerPlugin).
79+
settings(
80+
dockerBaseImage := "openjdk:jre-alpine",
81+
dockerAlias := com.typesafe.sbt.packager.docker.DockerAlias(None, Some("delphihub"),"delphi-cli", Some(version.value)),
82+
dockerEntrypoint := Seq("/bin/bash"),
83+
dockerCommands ++= Seq(
84+
Cmd("USER", "root"),
85+
Cmd("RUN", "apk", "--no-cache", "add", "bash"),
86+
Cmd("RUN", "ln", "-s", "/opt/docker/bin/delphi", "/usr/bin/delphi" ),
87+
Cmd("USER", "daemon")
88+
)
89+
).
3690
enablePlugins(ScalastylePlugin).
3791
enablePlugins(BuildInfoPlugin).
3892
enablePlugins(DebianPlugin).
3993
enablePlugins(WindowsPlugin).
40-
94+
enablePlugins(GraalVMNativeImagePlugin).
95+
settings(
96+
graalVMNativeImageOptions ++= Seq(
97+
"--enable-https",
98+
"--enable-http",
99+
"--enable-all-security-services",
100+
"--allow-incomplete-classpath",
101+
"--enable-url-protocols=http,https"
102+
)
103+
).
104+
enablePlugins(JDKPackagerPlugin).
41105
settings(
42106
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
43-
buildInfoPackage := "de.upb.cs.swt.delphi.cli"
107+
buildInfoPackage := "de.upb.cs.swt.delphi.cli",
108+
crossScalaVersions := supportedScalaVersions
44109
)
45110
scalastyleConfig := baseDirectory.value / "project" / "scalastyle-config.xml"
46111

47112
trapExit := false
113+
fork := true
114+
connectInput := true

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.1.1
1+
sbt.version = 1.2.8

project/plugins.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// build management and packaging
22
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
3-
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")
3+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.15")
44

55
// coverage
6-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
7-
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12")
6+
// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
7+
// addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.14")
88

99
// preparation for dependency checking
1010
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.1")

src/main/scala/de/upb/cs/swt/delphi/cli/Config.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ package de.upb.cs.swt.delphi.cli
2323
* @param verbose Marker if logging should be verbose
2424
* @param mode The command to be run
2525
*/
26-
case class Config(server: String = sys.env.getOrElse("DELPHI_SERVER", "https://delphi.cs.uni-paderborn.de/api/"),
26+
case class Config(server: String = sys.env.getOrElse("DELPHI_SERVER", "https://delphi.cs.uni-paderborn.de/api"),
2727
verbose: Boolean = false,
2828
raw: Boolean = false,
29+
csv: String = "",
2930
silent: Boolean = false,
3031
list : Boolean = false,
3132
mode: String = "",
3233
query : String = "",
3334
limit : Option[Int] = None,
3435
id : String = "",
36+
timeout : Option[Int] = None,
3537
args: List[String] = List(),
3638
opts: List[String] = List()) {
3739

3840
lazy val consoleOutput = new ConsoleOutput(this)
41+
lazy val csvOutput = new CsvOutput(this)
3942

4043
}

src/main/scala/de/upb/cs/swt/delphi/cli/ConsoleOutput.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package de.upb.cs.swt.delphi.cli
1818

1919
import de.upb.cs.swt.delphi.cli.artifacts.{RetrieveResult, SearchResult}
20+
import de.upb.cs.swt.delphi.client.FieldDefinition
2021

2122
class ConsoleOutput(config: Config) {
2223

@@ -45,6 +46,7 @@ class ConsoleOutput(config: Config) {
4546
}
4647
}
4748
case retrieveResults : Seq[RetrieveResult] if retrieveResults.head.isInstanceOf[RetrieveResult] => ResultBeautifier.beautifyRetrieveResults(retrieveResults)
49+
case featureResults : Seq[FieldDefinition] if featureResults.head.isInstanceOf[FieldDefinition] => ResultBeautifier.beautifyFeatures(featureResults)
4850
case _ => value.toString
4951
}
5052
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (C) 2018 The Delphi Team.
2+
// See the LICENCE file distributed with this work for additional
3+
// information regarding copyright ownership.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package de.upb.cs.swt.delphi.cli
18+
19+
import java.io.{BufferedWriter, FileWriter}
20+
21+
import de.upb.cs.swt.delphi.cli.artifacts.Result
22+
import au.com.bytecode.opencsv.CSVWriter
23+
24+
import scala.collection.JavaConverters._
25+
26+
/**
27+
* Export search and retrieve results to .csv file.
28+
*
29+
* @author Lisa Nguyen Quang Do
30+
* @author Ben Hermann
31+
*
32+
*/
33+
34+
class CsvOutput(config: Config) {
35+
36+
def exportResult(value: Any): Unit = {
37+
printToCsv(
38+
value match {
39+
case results :
40+
Seq[Result] if results.headOption.getOrElse(Seq.empty[Array[String]]).isInstanceOf[Result] => resultsToCsv(results)
41+
case _ => Seq.empty[Array[String]]
42+
}
43+
)
44+
}
45+
46+
def printToCsv(table : Seq[Array[String]]): Unit = {
47+
val outputFile = new BufferedWriter(new FileWriter(config.csv, /* append = */false))
48+
val csvWriter = new CSVWriter(outputFile)
49+
csvWriter.writeAll(seqAsJavaList(table))
50+
outputFile.close()
51+
}
52+
53+
def resultsToCsv(results : Seq[Result]) : Seq[Array[String]] = {
54+
val headOption = results.headOption.getOrElse()
55+
if (!headOption.isInstanceOf[Result]) {
56+
Seq.empty[Array[String]]
57+
} else {
58+
val fieldNames = headOption.asInstanceOf[Result].fieldNames()
59+
val tableHeader : Array[String] =
60+
fieldNames.+:("discovered at").+:("version").+:("groupId").+:("artifactId").+:("source").+:("Id").toArray
61+
results.map {
62+
e => {
63+
Array(e.id, e.metadata.source, e.metadata.artifactId, e.metadata.groupId, e.metadata.version,
64+
e.metadata.discovered).++(fieldNames.map(f => e.metricResults(f).toString))
65+
}
66+
}.+:(tableHeader)
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)