summaryrefslogtreecommitdiff
path: root/plugins/template/examples/example.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2020-07-13 15:28:40 -0400
committeranselor <anselor@gmail.com>2020-07-14 19:26:30 -0400
commite38684d219847f636562ab2720b82aae4a6fd408 (patch)
treeec20d7a46b8cba1a662d46e79d5e004590bee93b /plugins/template/examples/example.py
parent683d049299c0cf7a2821b639a95ad0911bab1bc7 (diff)
downloadcmd2-git-e38684d219847f636562ab2720b82aae4a6fd408.tar.gz
Brought in cmd2 plugin template as a first-class member of cmd2 proper
Diffstat (limited to 'plugins/template/examples/example.py')
-rw-r--r--plugins/template/examples/example.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/template/examples/example.py b/plugins/template/examples/example.py
new file mode 100644
index 00000000..2c9b8e5c
--- /dev/null
+++ b/plugins/template/examples/example.py
@@ -0,0 +1,21 @@
+#
+# coding=utf-8
+
+import cmd2
+import cmd2_myplugin
+
+
+class Example(cmd2_myplugin.MyPlugin, cmd2.Cmd):
+ """An class to show how to use a plugin"""
+ def __init__(self, *args, **kwargs):
+ # gotta have this or neither the plugin or cmd2 will initialize
+ super().__init__(*args, **kwargs)
+
+ @cmd2_myplugin.empty_decorator
+ def do_something(self, arg):
+ self.poutput('this is the something command')
+
+
+if __name__ == '__main__':
+ app = Example()
+ app.cmdloop()