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/18 08:35:18 UTC

[incubator-nlpcraft] branch NLPCRAFT-199 created (now a304f83)

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

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


      at a304f83  User home folder support (~) added for gen-model and gen-project commands.

This branch includes the following new commits:

     new a304f83  User home folder support (~) added for gen-model and gen-project commands.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a304f83aa718d70ffc1e7dcaf52350ca3b3a82b3
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Fri Dec 18 11:35: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