Skip to content

smelt.cmd

Tier: Host - Available in every runtime, including headless mode.

Visibility: Public - Stable Lua API intended for user config and plugins.

This namespace mixes Host and UiHost functions; each function below lists its exact tier.

Register and list slash commands. cmd.run is injected by the TUI layer so it can access the live app state.

smelt.cmd.list

fun(): table

Tier: Host - Available in every runtime, including headless mode.

Return every registered slash command as a Lua array of { name, desc, args, busy, startup_ok, hidden } rows. Sorted by name.

smelt.cmd.picker

fun(name: string, opts: table?): nil

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Register a slash command name that opens a prompt-docked picker when called without arguments, or invokes opts.apply(arg) directly when given one. See the file header for every accepted opts field (items, apply, on_enter, on_dismiss, stay_open, …). Returns nothing; the command lives until /reload or an explicit smelt.cmd.register{...}:remove() matching name.

smelt.cmd.register

fun(name: string, handler: fun(value: string?), opts: smelt.cmd.RegisterOpts?): smelt.Reg

Types: smelt.cmd.RegisterOpts, smelt.Reg

Tier: Host - Available in every runtime, including headless mode.

Register a slash command name whose handler is invoked when the user runs it. opts accepts desc, args, busy (run, reject, queue_request, or queue_command; default run), startup_ok (default false), hidden (default false), and override (default false). Returns a Reg whose :remove() unregisters the command.

smelt.cmd.run

fun(line: string): nil

Tier: UiHost - Requires a terminal UI; calling these from headless mode raises.

Execute the slash-command line line (with or without leading /) as if the user had typed it. Errors are surfaced as in-app notifications.