add project arguments table passing in app.start_background_instance

This commit is contained in:
MihailRis 2026-09-03 22:25:58 +03:00
parent 6b915b33a4
commit 2060f3f153

View file

@ -405,6 +405,20 @@ static int l_start_background_instance(lua::State* L) {
auto scriptPath = lua::require_lstring(L, 1); auto scriptPath = lua::require_lstring(L, 1);
io::path outputPath = lua::isstring(L, 2) ? lua::require_lstring(L, 2) : ""; io::path outputPath = lua::isstring(L, 2) ? lua::require_lstring(L, 2) : "";
std::vector<std::pair<std::string, std::string>> projectArgs;
if (lua::istable(L, 3)) {
lua::pushnil(L);
while (lua::next(L, 3)) {
lua::pushvalue(L, -2);
auto key = lua::tolstring(L, -1);
auto value = lua::tolstring(L, -2);
projectArgs.emplace_back(key, value);
lua::pop(L, 2);
}
lua::pop(L);
}
const auto& paths = engine->getPaths(); const auto& paths = engine->getPaths();
std::vector<std::string> args { std::vector<std::string> args {
@ -419,6 +433,17 @@ static int l_start_background_instance(lua::State* L) {
args.emplace_back("--project"); args.emplace_back("--project");
args.emplace_back(io::resolve(engine->getProject().path).u8string()); args.emplace_back(io::resolve(engine->getProject().path).u8string());
if (!projectArgs.empty()) {
args.emplace_back("--");
for (const auto& [key, value] : projectArgs) {
if (key.empty()) {
throw std::runtime_error("empty project argument name passed");
}
args.emplace_back("--" + key);
args.emplace_back(value);
}
}
int handle = -1; int handle = -1;
for (int i = 0; i < ::processes.size(); i++) { for (int i = 0; i < ::processes.size(); i++) {
if (!::processes[i] || !::processes[i]->isActive()) { if (!::processes[i] || !::processes[i]->isActive()) {