summaryrefslogtreecommitdiff
path: root/examples/extensions/greet.lua
blob: 30a6f12ba9a8709955bd37f012c1b783a6aa4141 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 <name>` 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.ext.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,
}