From e298f4dec521fc9e9abcaa9989a5c7b3fbbe8840 Mon Sep 17 00:00:00 2001
From: "alexey.stratulat" <alexey.stratulat@demlabs.net>
Date: Fri, 11 Feb 2022 19:06:10 +0700
Subject: [PATCH] [+] Added an example plugin that adds commands.

---
 .../plugins/demoCustomCMD/demoCustomCMD.py    | 34 +++++++++++++++++++
 .../plugins/demoCustomCMD/manifest.json       |  8 +++++
 2 files changed, 42 insertions(+)
 create mode 100644 dists/examples/plugins/demoCustomCMD/demoCustomCMD.py
 create mode 100644 dists/examples/plugins/demoCustomCMD/manifest.json

diff --git a/dists/examples/plugins/demoCustomCMD/demoCustomCMD.py b/dists/examples/plugins/demoCustomCMD/demoCustomCMD.py
new file mode 100644
index 00000000..cd1eb931
--- /dev/null
+++ b/dists/examples/plugins/demoCustomCMD/demoCustomCMD.py
@@ -0,0 +1,34 @@
+from API_CellFrame import logItNotice, AppCliServer
+
+"""
+This function takes two arguments
+argv is an array of incoming arguments
+indexStrReply is an internal index that correlates what is needed
+ to fill the desired buffer with the data that will be passed to the CLI.
+"""
+def cmdDemo(argv, indexStrReply):
+    reply = "Arguments :\n"
+    for i in range(len(argv)):
+        reply += "arg["+str(i)+"]: "+argv[i]+"\n"
+    AppCliServer.setReplyText(reply, indexStrReply)
+
+def cmdDemo2(argv, indexStrReply):
+    AppCliServer.setReplyText("I simple demo command", indexStrReply)
+
+def init():
+    logItNotice("Running plugin order")
+    """
+          The cmdItemCreate function creates a CLI command. 
+          This function takes four arguments.
+          Command name, command handler function, short description of 
+        of the command, full description of the command.
+    """
+    AppCliServer.cmdItemCreate("demo", cmdDemo, "Command demo",
+"""
+    This command is intended to demonstrate the work of custom command in the CellFrame API for Python.
+""")
+    AppCliServer.cmdItemCreate("demo2", cmdDemo2, "Second command demo",
+"""
+    This is demo and testing
+""")
+    return 0
diff --git a/dists/examples/plugins/demoCustomCMD/manifest.json b/dists/examples/plugins/demoCustomCMD/manifest.json
new file mode 100644
index 00000000..bf34c363
--- /dev/null
+++ b/dists/examples/plugins/demoCustomCMD/manifest.json
@@ -0,0 +1,8 @@
+{ 
+        "name": "demoCustomCMD",
+        "version": "1.0",
+        "author": "DEMLABS (C) 2022",
+        "dependencys": [],
+        "description": "This is a plugin example for working custom command."
+}
+
-- 
GitLab