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 070d338  WIP.
070d338 is described below

commit 070d3385afd09aa4285223ade2c4cb051b32edfe
Author: Aaron Radzinski <[email protected]>
AuthorDate: Wed Aug 26 14:26:53 2020 -0700

    WIP.
---
 .../nlpcraft/common/ascii/NCAsciiTable.scala       |  6 ++--
 .../model/tools/cmdline/NCCommandLine.scala        | 37 +++++++++++++++++++++-
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ascii/NCAsciiTable.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ascii/NCAsciiTable.scala
index 180ad36..1e1470d 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ascii/NCAsciiTable.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ascii/NCAsciiTable.scala
@@ -302,7 +302,7 @@ class NCAsciiTable {
      * @return
      */
     private def breakUpByNearestSpace(maxWidth: Int, lines: Seq[String]): 
Seq[String] =
-        lines.map(_.trim).flatMap(line => {
+        lines.flatMap(line => {
             if (line.isEmpty)
                 mutable.Buffer("")
             else {
@@ -317,7 +317,7 @@ class NCAsciiTable {
                     if (curr - start > maxWidth) {
                         val end = if (lastSpace == -1) curr else lastSpace + 1 
/* Keep space at the end of the line. */
 
-                        buf += line.substring(start, end).trim
+                        buf += line.substring(start, end)
                         start = end
                     }
 
@@ -328,7 +328,7 @@ class NCAsciiTable {
                 }
 
                 if (start < len) {
-                    val lastLine = line.substring(start).trim
+                    val lastLine = line.substring(start)
 
                     if (lastLine.nonEmpty)
                         buf += lastLine
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
index 60edc1c..591e212 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCommandLine.scala
@@ -33,6 +33,8 @@ object NCCommandLine extends App {
     private final lazy val SCRIPT = NCUtils.sysEnv("NLPCRAFT_CLI_SCRIPT")
     private final lazy val SCRIPT_NAME = SCRIPT.getOrElse("NLPCraft CLI")
 
+    private final val TAB4 = "    "
+
     // Single CLI command.
     case class Command(
         id: String,
@@ -101,6 +103,16 @@ object NCCommandLine extends App {
                     arity = (0, 1),
                     desc = "Flag to show full manual for all commands."
                 )
+            ),
+            examples = Seq(
+                Example(
+                    code = s"$$ $SCRIPT_NAME help repl",
+                    desc = "Displays help for 'repl' command"
+                ),
+                Example(
+                    code = s"$$ $SCRIPT_NAME help -all",
+                    desc = "Displays help for all commands."
+                )
             )
         ),
         Command(
@@ -152,7 +164,30 @@ object NCCommandLine extends App {
                     lines += cmd.synopsis
 
                 if (cmd.params.nonEmpty) {
-                    lines ++= Seq("", "PARAMETERS")
+                    lines += ""
+                    lines += "PARAMETERS"
+
+                    for (param <- cmd.params) {
+                        var nameLine = s"$TAB4${param.names.mkString(", ")}"
+
+                        if (param.valueDesc.isDefined)
+                            nameLine += s"=${param.valueDesc.get}"
+
+                        val nameDesc = s"$TAB4$TAB4${param.desc}"
+
+                        lines += nameLine
+                        lines += nameDesc
+                    }
+                }
+
+                if (cmd.examples.nonEmpty) {
+                    lines += ""
+                    lines += "EXAMPLES"
+
+                    for (ex <- cmd.examples) {
+                        lines += s"$TAB4${ex.code}"
+                        lines += s"$TAB4$TAB4${ex.desc}"
+                    }
                 }
 
                 tbl +/ (

Reply via email to