Files
lbs/include/lua_platform.h

35 lines
1.7 KiB
C

#pragma once
#include "lua_parallel.h"
// Platform-related code
// Provided variables;
// platform.os: string
// platform.arch: string
// platform.call_convention: string
// platform.isa_exts: table<string, boolean>
int luaopen_platform(lua_State* L);
// Returns the exit code of the command as well as a string of its stdout
// int, string, string function platform.exec(cmd: string, args: array<string>)
int lua_platform_exec(lua_State* L);
// Executes a command asynchronosly, returning a promise to the functions return values
// promise<int>, promise<string>, promise<string> function platform.exec_async(cmd: string, args: array<string>)
int lua_platform_exec_async(lua_State* L);
// Executes a command asynchronosly, calling a callback on its completion with its error code and
// overall stdout and another callback on each token read from its stdout
// function platform.exec_async_cb(cmd: string,
// function on_complete(cmd: string, exit_code: int, overall_output: string),
// function on_stdout(cmd: string, overall_output: string, delta_output: string)
// function on_stderr(cmd: string, overall_output: string, delta_output: string)
// )
int lua_platform_exec_async_cb(lua_State* L);
// Executes the same command up to N times in parallel, iterating through the args provided until all arguments have been used
// array[promise<int>, promise<string>, promise<string>] function platform.exec_parallel_async(cmd: string, N: int, args: array<array<string>>)
int lua_platform_exec_parallel_async(lua_State* L);
// array<int>, array<string>, array<string> function platform.exec_parallel(cmd: string, N: int, args: array<array<string>>)
int lua_platform_exec_parallel(lua_State* L);