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/12/19 13:38:18 UTC

[incubator-nlpcraft] branch master updated: User home folder support (~) added for gen-model and gen-project commands.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new a2f949a  User home folder support (~) added for gen-model and gen-project commands.
a2f949a is described below

commit a2f949ab0402d8bcb57fe373f99e80aeaf656493
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Sat Dec 19 16:38:08 2020 +0300

    User home folder support (~) added for gen-model and gen-project commands.
---
 .../org/apache/nlpcraft/model/tools/cmdline/NCCli.scala    | 14 ++++++++++++--
 1 file changed, 12 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 3531d3a..ee8fd55 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
@@ -1823,6 +1823,16 @@ object NCCli extends App {
 
     /**
       *
+      * @param path
+      */
+    private def refinePath(path: String): String = {
+        require(path != null)
+
+        if (path.nonEmpty && path.head == '~') new File(SystemUtils.getUserHome, path.tail).getAbsolutePath else path
+    }
+
+    /**
+      *
       * @param cmd
       * @param name
       * @param value
@@ -1970,7 +1980,7 @@ object NCCli extends App {
       * @param repl Whether or not executing from REPL.
       */
     private [cmdline] def cmdGenModel(cmd: Command, args: Seq[Argument], repl: Boolean): Unit = {
-        val filePath = get(cmd, args, "filePath")
+        val filePath = refinePath(get(cmd, args, "filePath"))
         val overrideFlag = get(cmd, args,"override", "false").toLowerCase
         val modelId = get(cmd, args,"modelId")
 
@@ -2020,7 +2030,7 @@ object NCCli extends App {
       * @param repl Whether or not executing from REPL.
       */
     private [cmdline] def cmdGenProject(cmd: Command, args: Seq[Argument], repl: Boolean): Unit = {
-        val outputDir = get(cmd, args, "outputDir", ".")
+        val outputDir = refinePath(get(cmd, args, "outputDir", "."))
         val baseName = get(cmd, args,"baseName")
         val lang = get(cmd, args,"lang", "java").toLowerCase
         val buildTool = get(cmd, args,"buildTool", "mvn").toLowerCase