shared
Cross-tool helpers for the blender toolbox. Every tool inside the toolbox can pull these in with `require(".shared")`. Holds the small set of helpers that more than one tool needs — typically the `ok(value, formatted?)` / `fail(message, exitCode?)` constructors that produce the c…
shared
Cross-tool helpers for the blender toolbox. Every tool inside the
toolbox can pull these in with require(".shared"). Holds the small
set of helpers that more than one tool needs — typically the
ok(value, formatted?) / fail(message, exitCode?) constructors that
produce the canonical blenderToolResult shape, plus any toolbox-wide
parsers, validators, or shared state. Per-tool implementation stays
inside each <x>.tool/init.luau; this module is not a place to
forward logic from.
Exports
M.ok(value: any?, formatted: string?) -> blenderToolResult— success envelope (exitCode = 0,ok = true).M.fail(message: string, exitCode: number?) -> blenderToolResult— failure envelope (exitCodedefaults to 1,ok = false).
Types:
blenderToolResult = { stdout: string, stderr: string, exitCode: number, ok: boolean, value: any? }stdout— human-readable formatted output; empty when the op produces no text.stderr— error message on failure; empty on success.exitCode— POSIX-style exit code:0success,1generic failure,2bad arguments.ok—trueiffexitCode == 0.value— structured return from the underlying op;nilfor void ops.
Usage
local shared = require(".shared")
function M.someTool(args)
if not args.id then
return shared.fail("missing id", 2)
end
return shared.ok({ id = args.id }, "created " .. args.id)
end
Notes
- Pure constructors — no engine calls, no state. Safe to call from any context.
- Tools that opt into this shape get a stable envelope every other tool
in the toolbox can rely on. Tools that do something custom can return
whatever shape they want —
blenderToolResultis opt-in. - Per-tool implementations still own their own
--!desc/--!arg/--!return/--!exampleannotations even when their result is constructed through these helpers.
Scoped to this part · feeds back into the world's score.