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 4d482a6  Update NCCli.scala
4d482a6 is described below

commit 4d482a668fb34c2969537dbb6892f22cca75fc4b
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sat Oct 3 23:47:31 2020 -0700

    Update NCCli.scala
---
 .../nlpcraft/model/tools/cmdline/NCCli.scala       | 52 +++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

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 9034419..797cff0 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
@@ -143,6 +143,46 @@ object NCCli extends App {
     // All supported commands.
     private final val CMDS = Seq(
         Command(
+            name = "rest",
+            synopsis = s"Issues REST call to locally running REST server.",
+            desc = Some(
+                s"All NLPCraft REST API uses HTTP POST and JSON parameters 
('Content-Type: application/json' header). " +
+                s"To issue the REST call you need to supply path and 
parameters. In REPL mode, hit ${rv(" Tab ")} to see auto-suggestion and " +
+                s"auto-completion candidates for commonly used paths and JSON 
payload components."
+            ),
+            body = cmdRest,
+            params = Seq(
+                Parameter(
+                    id = "config",
+                    names = Seq("--path", "-p"),
+                    value = Some("path"),
+                    desc =
+                        s"REST path, e.g. ${y("'/signin'")} or 
${y("'/ask/sync'")}. " +
+                        s"See more details at 
https://nlpcraft.apache.org/using-rest.html";
+                ),
+                Parameter(
+                    id = "json",
+                    names = Seq("--json", "-j"),
+                    value = Some("'json'"),
+                    desc =
+                        s"REST call parameters as JSON object. Since standard 
JSON only supports double " +
+                        s"quotes the entire JSON string should be enclosed in 
single quotes. You can " +
+                        s"find full OpenAPI specification for NLPCraft REST 
API at " +
+                        s"https://nlpcraft.apache.org/using-rest.html";
+                )
+            ),
+            examples = Seq(
+                Example(
+                    usage = Seq(
+                        s"$PROMPT $SCRIPT_NAME rest ",
+                        "  -p=/signin",
+                        "  -j='{\"email\": \"[email protected]\", \"passwd\": 
\"admin\"}'"
+                    ),
+                    desc = s"Issues ${y("/signin")} REST call with given JSON 
payload."
+                )
+            )
+        ),
+        Command(
             name = "start-server",
             synopsis = s"Starts local REST server.",
             desc = Some(
@@ -194,7 +234,7 @@ object NCCli extends App {
             examples = Seq(
                 Example(
                     usage = Seq(s"$PROMPT $SCRIPT_NAME start-server"),
-                    desc = "Starts local  server with default configuration."
+                    desc = "Starts local server with default configuration."
                 ),
                 Example(
                     usage = Seq(s"$PROMPT $SCRIPT_NAME start-server 
-c=/opt/nlpcraft/nlpcraft.conf"),
@@ -886,6 +926,16 @@ object NCCli extends App {
      * @param args Arguments, if any, for this command.
      * @param repl Whether or not executing from REPL.
      */
+    private def cmdRest(cmd: Command, args: Seq[Argument], repl: Boolean): 
Unit = {
+        // TODO
+    }
+
+    /**
+     *
+     * @param cmd Command descriptor.
+     * @param args Arguments, if any, for this command.
+     * @param repl Whether or not executing from REPL.
+     */
     private def cmdRepl(cmd: Command, args: Seq[Argument], repl: Boolean): 
Unit = {
         loadServerBeacon() match {
             case Some(beacon) ⇒ logln(s"Local REST server 
detected:\n${mkServerBeaconTable(beacon).toString}")

Reply via email to