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 <[email protected]> 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
