Module hilbish.processors

command processing before execution

Added in v3.0.0

Introduction#

The processors interface manages command processors, which are functions that can transform a command string before it is executed. Processors run in order of priority, lowest number first.

Functions#


add#

hilbish.processors.add(processor)

Registers a command processor. A processor is a table with at minimum a name and a func field. The func receives the command string and may return a table with any of: command (the new command string), continue (whether to abort execution if false), and modifiers.

Parameters#

table processor A table with name (string), func (function), and optional priority (number, default 0).

Example#

hilbish.processors.add({
	name = 'my-processor',
	priority = 0,
	func = function(cmd)
		-- do something with cmd
	end
})

execute#

hilbish.processors.execute(command, opts) -> table

Runs all registered processors against the provided command in priority order.

Parameters#

string command The command string to process.

table opts Optional

table<string> skip OptionalA list of processor names to skip.

Returns#

table The (possibly modified) result of running the processors.

string command The processed command string.

boolean continue Whether execution should proceed.

table modifiers Any modifier flags set by processors.