Skip to content

Release/0.9.5 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fcc916f
Adding --csv option to search and retrieve (Issue #4 )
sideresearch Nov 21, 2018
21560a2
Fixed the Buildinfo placeholder
nguyenLisa Nov 21, 2018
20427e6
Fixing code style issues.
sideresearch Nov 22, 2018
72add90
Fixing last code style issue
sideresearch Nov 22, 2018
655272a
Merge pull request #28 from delphi-hub/csv-option
bhermann Nov 24, 2018
40e8743
Catch the TimeoutException in the search command.
sideresearch Nov 24, 2018
d398c5b
Fixing code style.
sideresearch Nov 24, 2018
fb14f37
Fixed last style issues
sideresearch Nov 24, 2018
6ee305e
Merge pull request #30 from delphi-hub/search-timeout
bhermann Nov 28, 2018
96f1842
Refactoring delphi cli sttp dependency for native image generation
Jan 15, 2019
3972bd4
Refactored retrieve command to sttp
Jan 15, 2019
1de2c18
Fixing encoded url issue for retrieve command
Jan 23, 2019
b252d4e
Refactoring search command to sttp
Jan 24, 2019
0724269
Implementing codacy suggestions
Jan 25, 2019
cc33060
Fixing codacy issue
Mar 7, 2019
7d8068a
Renaming the project to delphi
Mar 7, 2019
1396373
Merge pull request #32 from delphi-hub/Feature/27/NativeExe
bhermann Mar 9, 2019
e179a15
Merge branch 'master' into develop
Nov 19, 2019
2ee1c51
Upgrading akka to 2.5.16
Nov 20, 2019
f1fcde7
Upgrading sbt-codacy to 1.3.14
Nov 20, 2019
4e6e968
Merge pull request #33 from delphi-hub/vulnerability_fix
bhermann Nov 21, 2019
b0d3e8d
Updated sbt file
bhermann Nov 21, 2019
37db71e
Merge branch 'develop' of github.com:delphi-hub/delphi-cli into develop
bhermann Nov 21, 2019
2835ad1
- Switching back scala version to Scala 2.12
Nov 22, 2019
d0d4452
Merge pull request #35 from delphi-hub/vulnerability_fix
bhermann Nov 26, 2019
8e7a377
Made scala 2.12 default
bhermann Dec 24, 2019
4062a33
Merge branch 'develop' of github.com:delphi-hub/delphi-cli into develop
bhermann Dec 24, 2019
f4c3e58
Update README.md
bhermann Jan 7, 2020
f78e63e
Removed coverage for now
bhermann Jan 7, 2020
066f666
SBT version bumped to 1.3.5
bhermann Jan 7, 2020
d9af2e3
Bumped dependencies, moved to Scala 2.13
bhermann Jan 7, 2020
32a45f0
Deactivated GraalVM specific lines. Bugfix for help text
bhermann Jan 7, 2020
0351ee8
Changes to reflect 0.9.5 API
bhermann Jan 7, 2020
f3b1a07
Changes to reflect 0.9.5 API
bhermann Jan 7, 2020
d48bf52
Added features command. Closes #25
bhermann Jan 7, 2020
70cad00
Updated README to new console parameters
bhermann Jan 7, 2020
568818e
Made a helpful runnable docker container possible
bhermann Jan 8, 2020
b7d5950
Bumped sbt and project version
bhermann Jan 8, 2020
518f76a
Reverted to sbt 1.2.8 because of travis *sigh*
bhermann Jan 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: scala
scala:
- 2.12.4
- 2.13.1
script:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; fi'
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; fi'
after_success:
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'
# - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Delphi Command-Line Interface (CLI)
# Delphi Command-Line Interface (CLI) <img src="https://github.com/delphi-hub/delphi/raw/master/img/delphi.png" align="right" height=140/>

The command-line interface for the Delphi platform.

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

|branch | status | codacy | snyk |
| :---: | :---: | :---: | :---: |
| 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) |
| 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)
|branch | status | codacy | coverage | snyk |
| :---: | :---: | :---: | :---: | :---: |
| 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) |
| 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)

## What is the Delphi Command-Line Interface?

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

```
$ delphi --help
Delphi Command Line Tool (1.0.0-SNAPSHOT)
Usage: delphi [test|retrieve|search] [options] <args>...
Delphi Command Line Tool (0.9.5-SNAPSHOT)
Usage: delphi-cli [test|features|retrieve|search] [options] <args>...

--version Prints the version of the command line tool.
--help Prints this help text.
Expand Down
97 changes: 82 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,47 +1,114 @@
scalaVersion := "2.12.4"
import com.typesafe.sbt.packager.docker._

ThisBuild / organization := "de.upb.cs.swt.delphi"
ThisBuild / organizationName := "Delphi Project"
ThisBuild / organizationHomepage := Some(url("https://delphi.cs.uni-paderborn.de/"))

ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/delphi-hub/delphi-cli"),
"scm:[email protected]:delphi-hub/delphi-cli.git"
)
)

ThisBuild / developers := List(
Developer(
id = "bhermann",
name = "Ben Hermann",
email = "[email protected]",
url = url("https://www.thewhitespace.de")
)
)

ThisBuild / description := "The command line client for Delphi"
ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt"))
ThisBuild / homepage := Some(url("https://delphi.cs.uni-paderborn.de/"))

lazy val scala212 = "2.12.10"
lazy val scala213 = "2.13.1"
lazy val supportedScalaVersions = List(scala213)

ThisBuild / scalaVersion := scala213

name := "delphi"
version := "1.0.0-SNAPSHOT"
version := "0.9.5"
maintainer := "Ben Hermann <[email protected]>"

licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html"))

packageSummary := "Windows Package for the Delphi CLI"
packageDescription := """Windows Package for the Delphi CLI"""
wixProductId := "ce07be71-510d-414a-92d4-dff47631848a"
wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424"

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

val akkaVersion = "2.5.14"
val akkaHttpVersion = "10.1.5"
val http4sVersion = "0.21.0-M6"

// Only necessary for SNAPSHOT releases
resolvers += Resolver.sonatypeRepo("snapshots")

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion
"org.http4s" %% "http4s-dsl" % http4sVersion,
"org.http4s" %% "http4s-blaze-client" % http4sVersion,
"org.http4s" %% "http4s-circe" % http4sVersion
)

libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.0"
libraryDependencies += "io.spray" %% "spray-json" % "1.3.3"
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.1"
libraryDependencies += "io.spray" %% "spray-json" % "1.3.5"
libraryDependencies += "de.vandermeer" % "asciitable" % "0.3.2"
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.5"
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.7"
libraryDependencies += "au.com.bytecode" % "opencsv" % "2.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.0" % "test"
libraryDependencies += "joda-time" % "joda-time" % "2.10.5"

libraryDependencies += "de.upb.cs.swt.delphi" %% "delphi-core" % "0.9.2"
libraryDependencies += "de.upb.cs.swt.delphi" %% "delphi-client" % "0.9.2"

libraryDependencies ++= Seq(
"com.softwaremill.sttp" %% "core" % "1.7.2",
"com.softwaremill.sttp" %% "spray-json" % "1.7.2"
)


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

lazy val cli = (project in file(".")).
enablePlugins(JavaAppPackaging).
enablePlugins(DockerPlugin).
settings(
dockerBaseImage := "openjdk:jre-alpine",
dockerAlias := com.typesafe.sbt.packager.docker.DockerAlias(None, Some("delphihub"),"delphi-cli", Some(version.value)),
dockerEntrypoint := Seq("/bin/bash"),
dockerCommands ++= Seq(
Cmd("USER", "root"),
Cmd("RUN", "apk", "--no-cache", "add", "bash"),
Cmd("RUN", "ln", "-s", "/opt/docker/bin/delphi", "/usr/bin/delphi" ),
Cmd("USER", "daemon")
)
).
enablePlugins(ScalastylePlugin).
enablePlugins(BuildInfoPlugin).
enablePlugins(DebianPlugin).
enablePlugins(WindowsPlugin).

enablePlugins(GraalVMNativeImagePlugin).
settings(
graalVMNativeImageOptions ++= Seq(
"--enable-https",
"--enable-http",
"--enable-all-security-services",
"--allow-incomplete-classpath",
"--enable-url-protocols=http,https"
)
).
enablePlugins(JDKPackagerPlugin).
settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "de.upb.cs.swt.delphi.cli"
buildInfoPackage := "de.upb.cs.swt.delphi.cli",
crossScalaVersions := supportedScalaVersions
)
scalastyleConfig := baseDirectory.value / "project" / "scalastyle-config.xml"

trapExit := false
fork := true
connectInput := true
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.1.1
sbt.version = 1.2.8
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// build management and packaging
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.15")

// coverage
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12")
// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
// addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.14")

// preparation for dependency checking
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.1")
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/de/upb/cs/swt/delphi/cli/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ package de.upb.cs.swt.delphi.cli
* @param verbose Marker if logging should be verbose
* @param mode The command to be run
*/
case class Config(server: String = sys.env.getOrElse("DELPHI_SERVER", "https://delphi.cs.uni-paderborn.de/api/"),
case class Config(server: String = sys.env.getOrElse("DELPHI_SERVER", "https://delphi.cs.uni-paderborn.de/api"),
verbose: Boolean = false,
raw: Boolean = false,
csv: String = "",
silent: Boolean = false,
list : Boolean = false,
mode: String = "",
query : String = "",
limit : Option[Int] = None,
id : String = "",
timeout : Option[Int] = None,
args: List[String] = List(),
opts: List[String] = List()) {

lazy val consoleOutput = new ConsoleOutput(this)
lazy val csvOutput = new CsvOutput(this)

}
2 changes: 2 additions & 0 deletions src/main/scala/de/upb/cs/swt/delphi/cli/ConsoleOutput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package de.upb.cs.swt.delphi.cli

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

class ConsoleOutput(config: Config) {

Expand Down Expand Up @@ -45,6 +46,7 @@ class ConsoleOutput(config: Config) {
}
}
case retrieveResults : Seq[RetrieveResult] if retrieveResults.head.isInstanceOf[RetrieveResult] => ResultBeautifier.beautifyRetrieveResults(retrieveResults)
case featureResults : Seq[FieldDefinition] if featureResults.head.isInstanceOf[FieldDefinition] => ResultBeautifier.beautifyFeatures(featureResults)
case _ => value.toString
}
}
Expand Down
69 changes: 69 additions & 0 deletions src/main/scala/de/upb/cs/swt/delphi/cli/CsvOutput.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (C) 2018 The Delphi Team.
// See the LICENCE file distributed with this work for additional
// information regarding copyright ownership.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package de.upb.cs.swt.delphi.cli

import java.io.{BufferedWriter, FileWriter}

import de.upb.cs.swt.delphi.cli.artifacts.Result
import au.com.bytecode.opencsv.CSVWriter

import scala.collection.JavaConverters._

/**
* Export search and retrieve results to .csv file.
*
* @author Lisa Nguyen Quang Do
* @author Ben Hermann
*
*/

class CsvOutput(config: Config) {

def exportResult(value: Any): Unit = {
printToCsv(
value match {
case results :
Seq[Result] if results.headOption.getOrElse(Seq.empty[Array[String]]).isInstanceOf[Result] => resultsToCsv(results)
case _ => Seq.empty[Array[String]]
}
)
}

def printToCsv(table : Seq[Array[String]]): Unit = {
val outputFile = new BufferedWriter(new FileWriter(config.csv, /* append = */false))
val csvWriter = new CSVWriter(outputFile)
csvWriter.writeAll(seqAsJavaList(table))
outputFile.close()
}

def resultsToCsv(results : Seq[Result]) : Seq[Array[String]] = {
val headOption = results.headOption.getOrElse()
if (!headOption.isInstanceOf[Result]) {
Seq.empty[Array[String]]
} else {
val fieldNames = headOption.asInstanceOf[Result].fieldNames()
val tableHeader : Array[String] =
fieldNames.+:("discovered at").+:("version").+:("groupId").+:("artifactId").+:("source").+:("Id").toArray
results.map {
e => {
Array(e.id, e.metadata.source, e.metadata.artifactId, e.metadata.groupId, e.metadata.version,
e.metadata.discovered).++(fieldNames.map(f => e.metricResults(f).toString))
}
}.+:(tableHeader)
}
}
}
Loading