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 5a0127d Update NCCli.scala
5a0127d is described below
commit 5a0127dc40560f0c8d2daf4fdfacaae7f2e7597f
Author: Aaron Radzinski <[email protected]>
AuthorDate: Fri Oct 2 23:57:35 2020 -0700
Update NCCli.scala
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 44 +++++++---------------
1 file changed, 13 insertions(+), 31 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 1a8442b..a8329b1 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -18,7 +18,6 @@
package org.apache.nlpcraft.model.tools.cmdline
import java.io.{File, FileInputStream, IOException, ObjectInputStream}
-import java.net.URL
import com.google.gson._
import javax.net.ssl.SSLException
@@ -183,11 +182,11 @@ object NCCli extends App {
examples = Seq(
Example(
usage = Seq(s"$PROMPT $SCRIPT_NAME start-server"),
- desc = "Starts REST server with default configuration."
+ desc = "Starts local server with default configuration."
),
Example(
usage = Seq(s"$PROMPT $SCRIPT_NAME start-server
-c=/opt/nlpcraft/nlpcraft.conf"),
- desc = "Starts REST server with alternative configuration
file."
+ desc = "Starts local REST server with alternative
configuration file."
)
)
),
@@ -226,42 +225,27 @@ object NCCli extends App {
),
Command(
name = "ping-server",
- synopsis = s"Pings REST server.",
+ synopsis = s"Pings local REST server.",
desc = Some(
- s"REST server is pinged using '/health' REST call to check its
live status."
+ s"REST server is pinged using '/health' REST call to check its
online status."
),
body = cmdPingServer,
params = Seq(
Parameter(
- id = "endpoint",
- names = Seq("--endpoint", "-e"),
- value = Some("url"),
- optional = true,
- desc =
- "REST server endpoint in 'http{s}://hostname:port'
format. " +
- "Default value is http://localhost:8081"
- ),
- Parameter(
id = "number",
names = Seq("--number", "-n"),
value = Some("num"),
optional = true,
desc =
- "Number of pings to perform. Must be an integer > 0."
+ "Number of pings to perform. Must be a number > 0.
Default is 1."
)
),
examples = Seq(
Example(
- usage = Seq(s"$PROMPT $SCRIPT_NAME ping-server"),
- desc = "Pings REST server one time."
- ),
- Example(
usage = Seq(
- s"$PROMPT $SCRIPT_NAME ping-server ",
- s" --endpoint=http://localhost:1234 ",
- s" -n=10"
+ s"$PROMPT $SCRIPT_NAME ping-server -n=10"
),
- desc = "Pings REST server at 'http://localhost:1234'
endpoint 10 times."
+ desc = "Pings local REST server 10 times."
)
)
),
@@ -549,13 +533,11 @@ object NCCli extends App {
* @param repl Whether or not executing from REPL.
*/
private def cmdPingServer(cmd: Command, args: Seq[Argument], repl:
Boolean): Unit = {
- val endpoint = args.find(_.parameter.id == "endpoint") match {
- case Some(arg) ⇒ new URL(arg.value.get).toURI.toString
- case None ⇒ loadServerBeacon() match {
- case Some(beacon) ⇒ s"http://${beacon.restEndpoint}"
- case None ⇒ throw new IllegalStateException(s"Cannot detect
locally running REST server.")
- }
+ val endpoint = loadServerBeacon() match {
+ case Some(beacon) ⇒ s"http://${beacon.restEndpoint}"
+ case None ⇒ throw new IllegalStateException(s"Cannot detect
locally running REST server.")
}
+
val num = args.find(_.parameter.id == "number") match {
case Some(arg) ⇒
try
@@ -564,7 +546,7 @@ object NCCli extends App {
case _ :Exception ⇒ throw new
IllegalArgumentException(s"Invalid number of pings: ${arg.value.get}")
}
- case None ⇒ 1
+ case None ⇒ 1 // Default.
}
var i = 0
@@ -911,7 +893,7 @@ object NCCli extends App {
names.map(name ⇒ mkCandidate(if (hasVal) name
+ "=" else name, name,null, !hasVal))
})
.asJava
-
+
case None ⇒ Seq.empty[Candidate].asJava
})
}