You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2020/11/06 14:59:23 UTC

[incubator-nlpcraft] branch NLPCRAFT-153 updated: WIP.

This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-153
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-153 by this push:
     new 08ff4a9  WIP.
08ff4a9 is described below

commit 08ff4a9c329e111a656b8666a1131286b342c8bf
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Fri Nov 6 17:59:17 2020 +0300

    WIP.
---
 .../apache/nlpcraft/model/tools/cmdline/NCCli.scala  | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 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 cd003b6..c0184e4 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
@@ -28,6 +28,7 @@ import java.util.Date
 import java.util.regex.Pattern
 import java.util.zip.ZipInputStream
 
+import javax.lang.model.SourceVersion
 import javax.net.ssl.SSLException
 import org.apache.commons.io.IOUtils
 import org.apache.commons.io.input.{ReversedLinesFileReader, Tailer, TailerListenerAdapter}
@@ -2679,19 +2680,23 @@ object NCCli extends App {
         val packName = get(cmd, args,"packageName").toLowerCase
         val fileType = getOrDefault(args,"fileType", "yaml").toLowerCase
         val overrideFlag = getOrDefault(args,"override", "false").toLowerCase
+        val dst = new File(outputDir, baseName)
+        val packDir = packName.replaceAll("\\.", "/")
+        val className = s"${baseName.head.toUpper}${baseName.tail}"
+        val mdlFileName = s"$baseName.$fileType"
+        val inFolder = s"nlpcraft-$lang-$buildTool"
 
         check(cmd, "lang", lang, "java", "scala", "groovy", "kotlin")
         check(cmd,"buildTool", buildTool, "mvn", "grape", "gradle", "sbt")
         check(cmd,"fileType", fileType, "yaml", "yml", "json", "js")
         check(cmd,"overrideFlag", overrideFlag, "true", "false")
 
-        // TODO: check valid package name.
+        def checkJavaName(v: String, name: String): Unit =
+            if (!SourceVersion.isName(v))
+                throw InvalidParameter(cmd, name)
 
-        val dst = new File(outputDir, baseName)
-        val packDir = packName.replaceAll("\\.", "/")
-        val className = s"${baseName.head.toUpper}${baseName.tail}"
-        val mdlFileName = s"$baseName.$fileType"
-        val inFolder = s"nlpcraft-$lang-$buildTool"
+        checkJavaName(className, "baseName")
+        checkJavaName(packName, "packageName")
 
         @throws[NCE]
         def cp0(inEntry: String, outEntry: String, rs: Replacement*): Unit =
@@ -3481,6 +3486,3 @@ object NCCli extends App {
     // Boot up.
     boot(args)
 }
-
-object x extends App {
-}