Files
manual_slop/scripts/tool_call.cpp
2026-02-27 22:10:46 -05:00

57 lines
1.4 KiB
C++

#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
#include <process.h>
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "No tool name provided" << std::endl;
return 1;
}
std::string tool_name = argv[1];
// Construct the command: uv run python scripts/tool_call.py <tool_name>
std::string command = "uv run python scripts/tool_call.py " + tool_name;
// Use CreateProcess to run the command and handle pipes
STARTUPINFOA si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
ZeroMemory(&pi, sizeof(pi));
// Create the process
if (!CreateProcessA(
NULL,
(char*)command.c_str(),
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi
)) {
std::cerr << "CreateProcess failed (" << GetLastError() << ")" << std::endl;
return 1;
}
// Wait for the process to finish
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exit_code;
GetExitCodeProcess(pi.hProcess, &exit_code);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return exit_code;
}