Skip to content

Commit 53ea08b

Browse files
committed
Added color
1 parent 08363b2 commit 53ea08b

File tree

6 files changed

+12
-4
lines changed

6 files changed

+12
-4
lines changed

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ libraryDependencies ++= Seq(
2222
)
2323

2424
libraryDependencies += "de.vandermeer" % "asciitable" % "0.3.2"
25+
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.5"
26+
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
2527

2628
debianPackageDependencies := Seq("java8-runtime-headless")
2729

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class ConsoleOutput(config: Config) {
2525
if (!config.silent) println(value)
2626
}
2727

28+
def outputSuccess(value : String) : Unit = {
29+
//noinspection ScalaStyle
30+
if(!config.silent) println(fansi.Color.Green(value))
31+
}
32+
2833
def outputResult(value: Any): Unit = {
2934
//noinspection ScalaStyle
3035
println(
@@ -44,6 +49,6 @@ class ConsoleOutput(config: Config) {
4449

4550
def outputError(value : String) : Unit = {
4651
//noinspection ScalaStyle
47-
println(value)
52+
println(fansi.Color.Red(value))
4853
}
4954
}

src/main/scala/de/upb/cs/swt/delphi/cli/commands/Command.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ trait Command {
7878
protected def information(implicit config: Config): String => Unit = config.consoleOutput.outputInformation _
7979
protected def reportResult(implicit config: Config): Any => Unit = config.consoleOutput.outputResult _
8080
protected def error(implicit config: Config): String => Unit = config.consoleOutput.outputError _
81+
protected def success(implicit config: Config): String => Unit = config.consoleOutput.outputSuccess _
8182

8283
}

src/main/scala/de/upb/cs/swt/delphi/cli/commands/RetrieveCommand.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object RetrieveCommand extends Command with SprayJsonSupport with DefaultJsonPro
7373
}
7474

7575
val unmarshalled = Await.result(unmarshalledFuture, Duration.Inf)
76-
information(config)(s"Found ${unmarshalled.size} item(s).")
76+
success(config)(s"Found ${unmarshalled.size} item(s).")
7777
reportResult(config)(unmarshalled)
7878

7979
Await.ready(unmarshalledFuture, Duration.Inf)

src/main/scala/de/upb/cs/swt/delphi/cli/commands/SearchCommand.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ object SearchCommand extends Command with SprayJsonSupport with DefaultJsonProto
101101
=> ""
102102
}
103103
}
104-
information(config)(s"Found ${unmarshalled.size} item(s). $capMessage")
104+
success(config)(s"Found ${unmarshalled.size} item(s). $capMessage")
105105
reportResult(config)(unmarshalled)
106106

107107

src/main/scala/de/upb/cs/swt/delphi/cli/commands/TestCommand.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object TestCommand extends Command {
2727
override def execute(config: Config)(implicit system : ActorSystem): Unit = executeGet(
2828
"/version"
2929
)(config, system).map(s => {
30-
information(config)("Successfully contacted Delphi server. ")
30+
success(config)("Successfully contacted Delphi server. ")
3131
information(config)("Server version: " + s)
3232
})
3333
}

0 commit comments

Comments
 (0)