From 442888c6c306cfff0708c3d4bbbeda685cec2e75 Mon Sep 17 00:00:00 2001 From: t Date: Tue, 2 Jun 2026 19:41:56 -0600 Subject: lua /commands --- examples/extensions/greet.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/extensions/greet.lua (limited to 'examples/extensions/greet.lua') diff --git a/examples/extensions/greet.lua b/examples/extensions/greet.lua new file mode 100644 index 0000000..5ec406f --- /dev/null +++ b/examples/extensions/greet.lua @@ -0,0 +1,16 @@ +-- A trivial Lua slash command that greets the user. +-- Drop this under .panto/extensions/ (project) or your user config's +-- extensions/ dir, then type `/greet` or `/greet ` in the REPL. +-- +-- Slash-command handlers run synchronously and act by side effect (here, +-- writing to stdout). `args` is the trimmed text after the command name; +-- it is an empty string when none was given. The return value is ignored. + +panto.register_command { + name = "greet", + description = "Print a greeting. Optional args name who to greet.", + handler = function(args) + local who = args ~= "" and args or "world" + io.write("\n[greet] hello, " .. who .. "!\n") + end, +} -- cgit v1.3