summaryrefslogtreecommitdiff
path: root/lib/lua-repl/repl/plugins/example.lua
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-12-13 16:10:08 +1100
committerjacqueline <me@jacqueline.id.au>2023-12-13 16:10:08 +1100
commit64b106c13e18c33be0f2b0de532054e0ed3f731d (patch)
treeb54b1c90d941bc456b4d51e864970720bdf2d648 /lib/lua-repl/repl/plugins/example.lua
parent5a2f0b08e0e3f20cda977b510b680d5843ae7283 (diff)
downloadtangara-fw-64b106c13e18c33be0f2b0de532054e0ed3f731d.tar.gz
add a cool lua repl
Diffstat (limited to 'lib/lua-repl/repl/plugins/example.lua')
-rw-r--r--lib/lua-repl/repl/plugins/example.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/lua-repl/repl/plugins/example.lua b/lib/lua-repl/repl/plugins/example.lua
new file mode 100644
index 00000000..d55fd076
--- /dev/null
+++ b/lib/lua-repl/repl/plugins/example.lua
@@ -0,0 +1,41 @@
+-- Example plugin that demonstrates the objects available to a
+-- plugin, as well as the methods that a plugin should make use
+-- of
+
+-- Adding methods and properties to the repl object adds them to
+-- the REPL object loading the plugin. If such a method or property
+-- already exists, the current plugin will fail to load.
+function repl:newmethod(...)
+end
+
+-- Adding methods to the before object causes them to be called
+-- before the actual method itself. If the method being added
+-- (in this case displayresults) does not exist on the REPL object
+-- loading this plugin, the current plugin will fail to load.
+function before:displayresults(results)
+end
+
+-- Adding methods to the after object causes them to be called
+-- after the actual method itself. If the method being added
+-- (in this case displayresults) does not exist on the REPL object
+-- loading this plugin, the current plugin will fail to load.
+function after:displayresults(results)
+end
+
+-- Adding methods to the around object causes them to be called
+-- instead of the original method of the same name. The new
+-- method receives all of the arguments that the original would,
+-- except it also receives the original method as the first argument.
+-- This way, the new method may invoke the original as it pleases.
+-- If the method being added (in this case displayresults) does not exist on
+-- the REPL object loading this plugin, the current plugin will fail to load.
+function around:evalute(orig, chunk)
+end
+
+-- Adding methods to the override object causes them to be called
+-- instead of the original method of the same name. If the method being added
+-- (in this case displayresults) does not exist on the REPL object loading this
+-- plugin, the current plugin will fail to load.
+function override:name()
+ return 'Plugin!'
+end