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"
#include "temu-c/Support/Logging.h"
#include "temu-c/Support/config.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");
(void)data;
temu_logInfo(NULL, "mycommand executed with object %s",
temu_nameForObject(obj));
return 0;
}
data_t data;
TEMU_PLUGIN_MD_DEF_V1 = {.MDVersion = 1,
.Vendor = "Terma",
.PluginName = "TutorialCustomCommand",
.Major = 1,
.Minor = 0,
.Patch = 0,
.ABI_MAJOR = TEMU_MAJOR_VERSION,
.ABI_MINOR = TEMU_MINOR_VERSION,
.ABI_PATCH = TEMU_PATCH_VERSION,
.Flags = 0,
.Revision = TEMU_GIT_REVISION,
.License = "Tutorial",
.Description = "Tutorial command plugin",
.Copyright = "Terma",
.ExportControl = "None"};
TEMU_PLUGIN_INIT
{
void *cmd = temu_createCmd("mycommand", mycmdfunc,
"some documentation string", &data);
temu_cmdAddOption(cmd, "foo", teCOK_Object, 1, "object name", NULL);
}