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 e7f34f7 Update NCCli.scala
e7f34f7 is described below
commit e7f34f7ffaa3842f3d01ca782a4698dae82535b7
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sun Oct 11 06:04:44 2020 -0700
Update NCCli.scala
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 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 d78062d..d88bb73 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
@@ -105,6 +105,16 @@ object NCCli extends App {
s"Missing mandatory parameter: $C${"'" + cmd.params.find(_.id ==
paramId).get.names.head + "'"}$RST, " +
s"type $C'help --cmd=${cmd.name}'$RST to get help."
)
+ case class InvalidParameter(cmd: Command, paramId: String)
+ extends IllegalArgumentException(
+ s"Invalid parameter: $C${"'" + cmd.params.find(_.id ==
paramId).get.names.head + "'"}$RST, " +
+ s"type $C'help --cmd=${cmd.name}'$RST to get help."
+ )
+ case class InvalidJsonParameter(cmd: Command, param: String)
+ extends IllegalArgumentException(
+ s"Invalid JSON parameter: $C${"'$param'"}$RST, " +
+ s"type $C'help --cmd=${cmd.name}'$RST to get help."
+ )
case class HttpError(httpCode: Int)
extends IllegalStateException(s"REST error (HTTP ${c(httpCode)}).")
case class MalformedJson()
@@ -1204,7 +1214,7 @@ object NCCli extends App {
try
Integer.parseInt(arg.value.get)
catch {
- case _ :Exception ⇒ throw new
IllegalArgumentException(s"Invalid number of lines: ${arg.value.get}")
+ case _ :Exception ⇒ throw InvalidParameter(cmd, lines)
}
case None ⇒ 20 // Default.
@@ -1244,7 +1254,7 @@ object NCCli extends App {
try
Integer.parseInt(arg.value.get)
catch {
- case _ :Exception ⇒ throw new
IllegalArgumentException(s"Invalid number of pings: ${arg.value.get}")
+ case _ :Exception ⇒ throw InvalidParameter(cmd, "number")
}
case None ⇒ 1 // Default.
@@ -1719,6 +1729,14 @@ object NCCli extends App {
val path = normArgs.find(_.parameter.id == "path").getOrElse(throw
MissingParameter(cmd, "path")).value.get
checkRestPath(path)
+
+ val first = true
+
+ for (arg ← synthArgs) {
+ val jsName = arg.value.getOrElse(throw InvalidJsonParameter(cmd,
""))
+ }
+
+
}
/**