This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-108
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-108 by this push:
new 6574ff0 WIP.
6574ff0 is described below
commit 6574ff03ee420e54957d2f03fed6e7bea9e2d9d0
Author: Aaron Radzinski <[email protected]>
AuthorDate: Mon Sep 28 01:07:39 2020 -0700
WIP.
---
bin/nlpcraft.cmd | 8 +++---
bin/nlpcraft.sh | 6 ++--
nlpcraft/pom.xml | 3 ++
.../org/apache/nlpcraft/common/ansi/NCAnsi.scala | 32 ++++++++++++++++++++--
.../nlpcraft/common/ansi/NCAnsiSpinner.scala | 19 +++++++++----
.../model/tools/cmdline/NCCommandLine.scala | 14 +++++++++-
6 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/bin/nlpcraft.cmd b/bin/nlpcraft.cmd
index d1e147b..d1d7a87 100644
--- a/bin/nlpcraft.cmd
+++ b/bin/nlpcraft.cmd
@@ -31,7 +31,7 @@ if defined JAVA_HOME goto checkJdk
echo ERROR:
echo ------
echo JAVA_HOME environment variable is not found.
- echo Please point JAVA_HOME variable to location of JDK 1.8 or later.
+ echo Please point JAVA_HOME variable to location of JDK 11 or later.
echo You can also download latest JDK at http://java.com/download.
goto :eof
@@ -41,7 +41,7 @@ if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion
echo ERROR:
echo ------
echo JAVA is not found in JAVA_HOME=%JAVA_HOME%.
- echo Please point JAVA_HOME variable to installation of JDK 1.8 or later.
+ echo Please point JAVA_HOME variable to installation of JDK 11 or later.
echo You can also download latest JDK at http://java.com/download.
goto :eof
@@ -59,11 +59,11 @@ set JAVA_VER_STR=%JAVA_VER_STR:"=%
for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set
MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b
if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER%
-if %MAJOR_JAVA_VER% LSS 8 (
+if %MAJOR_JAVA_VER% LSS 11 (
echo ERROR:
echo ------
echo The version of JAVA installed in %JAVA_HOME% is incorrect.
- echo Please point JAVA_HOME variable to installation of JDK 1.8 or later.
+ echo Please point JAVA_HOME variable to installation of JDK 11 or later.
echo You can also download latest JDK at http://java.com/download.
goto :eof
)
diff --git a/bin/nlpcraft.sh b/bin/nlpcraft.sh
index f7d655b..74f3c08 100644
--- a/bin/nlpcraft.sh
+++ b/bin/nlpcraft.sh
@@ -67,7 +67,7 @@ checkJava() {
echo "ERROR:"
echo "------"
echo "JAVA_HOME environment variable is not found."
- echo "Please point JAVA_HOME variable to location of JDK 1.8 or
later."
+ echo "Please point JAVA_HOME variable to location of JDK 11 or
later."
echo "You can also download latest JDK at http://java.com/download"
exit 1
@@ -81,11 +81,11 @@ checkJava() {
# Check JDK.
javaMajorVersion "$JAVA"
- if [ "$version" -lt 8 ]; then
+ if [ "$version" -lt 11 ]; then
echo "ERROR:"
echo "------"
echo "The $version version of JAVA installed in JAVA_HOME=$JAVA_HOME
is incompatible."
- echo "Please point JAVA_HOME variable to installation of JDK 1.8 or
later."
+ echo "Please point JAVA_HOME variable to installation of JDK 11 or
later."
echo "You can also download latest JDK at http://java.com/download"
exit 1
diff --git a/nlpcraft/pom.xml b/nlpcraft/pom.xml
index 350e7f8..eef8bbd 100644
--- a/nlpcraft/pom.xml
+++ b/nlpcraft/pom.xml
@@ -495,6 +495,9 @@
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.apache.nlpcraft.NCStart</mainClass>
+ <manifestEntries>
+ <Multi-Release>true</Multi-Release>
+ </manifestEntries>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsi.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsi.scala
index 8accbcc..575ace1 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsi.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsi.scala
@@ -61,11 +61,19 @@ sealed trait NCAnsi extends LazyLogging {
// Cursor moves.
private final val CURSOR_UP = "\u001b[1A"
private final val CURSOR_DOWN = "\u001b[1B"
- private final val CURSOR_LEFT = "\u001b[1C"
- private final val CURSOR_RIGHT = "\u001b[1D"
+ private final val CURSOR_LEFT = "\u001b[1D"
+ private final val CURSOR_RIGHT = "\u001b[1C"
+ private final val CURSOR_POS_SAVE= "\u001b[s"
+ private final val CURSOR_POS_RESTORE = "\u001b[u"
+ private final val CURSOR_LINE_HOME = "\u001b[0G"
+ private final val CURSOR_SCREEN_HOME = "\u001b[H"
+ private final val CURSOR_HIDE = "\u001b[?25l"
+ private final val CURSOR_SHOW = "\u001b[?25h"
+
def isEnabled: Boolean = !U.isSysEnvTrue(PROP)
+ // Color functions.
def ansiBlackFg: String = if (isEnabled) BLACK else ""
def ansiBlackBg: String = if (isEnabled) BLACK_B else ""
def ansiRedFg: String = if (isEnabled) RED else ""
@@ -97,6 +105,26 @@ sealed trait NCAnsi extends LazyLogging {
def ansiWhite(s: String): String = s"$ansiWhiteFg$s$ansiReset"
def ansiBlue(s: String): String = s"$ansiBlueFg$s$ansiReset"
def ansiBold(s: String): String = s"$ansiBold$s$ansiReset"
+
+ // Erase functions.
+ def ansiClearScreen: String = if (isEnabled) CLEAR_SCREEN else ""
+ def ansiClearScreenAfter: String = if (isEnabled) CLEAR_SCREEN_AFTER else
""
+ def ansiClearScreenBefore: String = if (isEnabled) CLEAR_SCREEN_BEFORE
else ""
+ def ansiClearLine: String = if (isEnabled) CLEAR_LINE else ""
+ def ansiClearLineAfter: String = if (isEnabled) CLEAR_LINE_AFTER else ""
+ def ansiClearLineBefore: String = if (isEnabled) CLEAR_LINE_BEFORE else ""
+
+ // Cursor movement functions.
+ def ansiCursorUp: String = if (isEnabled) CURSOR_UP else ""
+ def ansiCursorDown: String = if (isEnabled) CURSOR_DOWN else ""
+ def ansiCursorLeft: String = if (isEnabled) CURSOR_LEFT else ""
+ def ansiCursorRight: String = if (isEnabled) CURSOR_RIGHT else ""
+ def ansiCursorLineHome: String = if (isEnabled) CURSOR_LINE_HOME else ""
+ def ansiCursorScreenHome: String = if (isEnabled) CURSOR_SCREEN_HOME else
""
+ def ansiCursorPosSave: String = if (isEnabled) CURSOR_POS_SAVE else ""
+ def ansiCursorPosRestore: String = if (isEnabled) CURSOR_POS_RESTORE else
""
+ def ansiCursorShow: String = if (isEnabled) CURSOR_SHOW else ""
+ def ansiCursorHide: String = if (isEnabled) CURSOR_HIDE else ""
}
object NCAnsi extends NCAnsi {
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiSpinner.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiSpinner.scala
index 6c60f8a..9dc91f2 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiSpinner.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiSpinner.scala
@@ -28,6 +28,8 @@ import org.apache.nlpcraft.common._
class NCAnsiSpinner(out: PrintStream = System.out, ansiColor: String =
ansiCyanFg) {
@volatile var thread: Thread = _
+ final val IS_ANSI = NCAnsi.isEnabled
+
final val SPIN_CHARS = Seq('-', '\\', '|', '/')
final val SPIN_CHARS_SIZE = SPIN_CHARS.size
@@ -36,14 +38,15 @@ class NCAnsiSpinner(out: PrintStream = System.out,
ansiColor: String = ansiCyanF
*/
def start(): Unit = {
thread = U.mkThread("ansi-spinner") { t ⇒
- val ansi = NCAnsi.isEnabled
-
var i = 0
+ if (IS_ANSI)
+ out.print(s"$ansiCursorHide")
+
while (!t.isInterrupted) {
- if (ansi) {
+ if (IS_ANSI) {
if (i > 0)
- out.print(ansi)
+ out.print(s"$ansiCursorLeft$ansiClearLineAfter")
out.print(s"$ansiColor${SPIN_CHARS(i %
SPIN_CHARS_SIZE)}$ansiReset")
@@ -52,7 +55,7 @@ class NCAnsiSpinner(out: PrintStream = System.out, ansiColor:
String = ansiCyanF
else
out.print(".")
- Thread.sleep(if (ansi) 300 else 1000)
+ Thread.sleep(if (IS_ANSI) 200 else 1000)
}
}
@@ -62,6 +65,10 @@ class NCAnsiSpinner(out: PrintStream = System.out,
ansiColor: String = ansiCyanF
/**
*
*/
- def stop(): Unit =
+ def stop(): Unit = {
U.stopThread(thread)
+
+ if (IS_ANSI)
+ out.print(s"$ansiCursorLeft$ansiClearLineAfter$ansiCursorShow")
+ }
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
index d17ef94..f80ac07 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
@@ -28,7 +28,7 @@ import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.HttpClients
import org.apache.nlpcraft.common.ascii.NCAsciiTable
import org.apache.nlpcraft.common._
-import org.apache.nlpcraft.common.ansi.NCAnsi
+import org.apache.nlpcraft.common.ansi.{NCAnsi, NCAnsiSpinner}
import org.apache.nlpcraft.common.ansi.NCAnsi._
import org.apache.nlpcraft.common.version.NCVersion
import resource.managed
@@ -340,7 +340,19 @@ object NCCommandLine extends App {
case None ⇒ 1
}
+ var i = 0
+ while (i < num) {
+ `>>`(s"Pinging ${ansiBlue(endpoint)} ")
+
+ val spinner = new NCAnsiSpinner()
+
+ spinner.start()
+
+ i += 1
+ }
+
+ Thread.sleep(100000)