Fügt CLI-Toolverwaltung und erweiterte UI-Funktionen hinzu
Ermöglicht die Verwaltung (Erstellen, Auflisten, Ausführen) von Tools über eine Befehlszeilenschnittstelle für Automatisierung und Integration. Die Benutzeroberfläche wurde mit dedizierten Ansichten für Toolerstellung und -bearbeitung, In-App-Lua-Hilfe sowie kontextsensitiven Menüs erweitert. Neue Abhängigkeiten (CLI11, rang) wurden integriert und eine umfassende Testsuite hinzugefügt. Die Lizenzierung wurde auf AGPL-3.0 umgestellt und ein Kontributionsleitfaden bereitgestellt.
This commit is contained in:
@@ -5,23 +5,54 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class LuaRunner {
|
||||
public:
|
||||
using CompletionCallback = std::function<void()>;
|
||||
using CompletionCallback = std::function<void(bool)>;
|
||||
|
||||
void run(int id, const std::filesystem::path& scriptPath, int timeoutSeconds, CompletionCallback onComplete);
|
||||
void cancel(int id);
|
||||
struct RunResult {
|
||||
bool started = false;
|
||||
bool singleInstance = false;
|
||||
};
|
||||
|
||||
struct TaskStatus {
|
||||
bool singleInstance = false;
|
||||
bool running = false;
|
||||
};
|
||||
|
||||
RunResult run(const std::string& taskId, const std::filesystem::path& scriptPath,
|
||||
int timeoutSeconds, CompletionCallback onComplete);
|
||||
TaskStatus status(const std::string& taskId, const std::filesystem::path& scriptPath) const;
|
||||
void cancel(const std::string& taskId) const;
|
||||
void shutdown() const;
|
||||
|
||||
~LuaRunner();
|
||||
|
||||
private:
|
||||
struct LuaTask {
|
||||
std::shared_ptr<std::atomic_bool> cancel;
|
||||
std::shared_ptr<std::atomic_bool> executionFinished;
|
||||
std::shared_ptr<std::atomic_bool> callbackFinished;
|
||||
bool singleInstance = false;
|
||||
std::jthread worker;
|
||||
|
||||
LuaTask(std::shared_ptr<std::atomic_bool> cancelFlag,
|
||||
std::shared_ptr<std::atomic_bool> executionFinishedFlag,
|
||||
std::shared_ptr<std::atomic_bool> callbackFinishedFlag,
|
||||
bool isSingleInstance)
|
||||
: cancel(std::move(cancelFlag)),
|
||||
executionFinished(std::move(executionFinishedFlag)),
|
||||
callbackFinished(std::move(callbackFinishedFlag)),
|
||||
singleInstance(isSingleInstance) {}
|
||||
};
|
||||
|
||||
struct State {
|
||||
std::mutex tasksMutex;
|
||||
std::unordered_map<int, LuaTask> tasks;
|
||||
std::unordered_map<std::string, std::vector<LuaTask>> tasks;
|
||||
};
|
||||
|
||||
std::shared_ptr<State> m_state = std::make_shared<State>();
|
||||
|
||||
Reference in New Issue
Block a user