Scripting
In TEMU 2.2 a command API has been added.
It is now possible to register commands using either the TEMU API or the python wrappers.
A plug-in can include temu-c/Support/CommandLine.h
and then register commands using the temu_createCmd
function:
#include "temu-c/Support/Objsys.h"
#include "temu-c/Support/CommandLine.h"
typedef struct {
int a;
} data_t;
int
mycmdfunc(void *ctxt)
{
void *data = temu_cmdGetData(ctxt); // returns dataptr
// Return pointer to obj in param "foo"
void *obj = temu_cmdGetOptionAsObject(ctxt, "foo");
temu_logInfo(NULL, "mycommand executed with object % s",
temu_nameForObject(obj));
}
data_t data;
TEMU_PLUGIN_INIT
{
void *cmd = temu_createCmd("mycommand", mycmdfunc,
"some documentation string", &data);
temu_cmdAddOption(cmd, "foo", teCOK_Object, 1, "object name", NULL);
}