aboutsummaryrefslogtreecommitdiff
path: root/libs/lootcli/include
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/lootcli/include
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/lootcli/include')
-rw-r--r--libs/lootcli/include/lootcli/lootcli.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/libs/lootcli/include/lootcli/lootcli.h b/libs/lootcli/include/lootcli/lootcli.h
new file mode 100644
index 0000000..90305a6
--- /dev/null
+++ b/libs/lootcli/include/lootcli/lootcli.h
@@ -0,0 +1,116 @@
+#ifndef MODORGANIZER_LOOTCLI_INCLUDED
+#define MODORGANIZER_LOOTCLI_INCLUDED
+
+#include <regex>
+
+namespace lootcli
+{
+
+enum class LogLevels
+{
+ Trace = 0,
+ Debug,
+ Info,
+ Warning,
+ Error
+};
+
+inline LogLevels logLevelFromString(const std::string& s)
+{
+ if (s == "trace") {
+ return LogLevels::Trace;
+ } else if (s == "debug") {
+ return LogLevels::Debug;
+ } else if (s == "info") {
+ return LogLevels::Info;
+ } else if (s == "warning") {
+ return LogLevels::Warning;
+ } else if (s == "error") {
+ return LogLevels::Error;
+ } else {
+ return LogLevels::Info;
+ }
+}
+
+inline std::string logLevelToString(LogLevels level)
+{
+ switch (level) {
+ case LogLevels::Trace:
+ return "trace";
+ case LogLevels::Debug:
+ return "debug";
+ case LogLevels::Info:
+ return "info";
+ case LogLevels::Warning:
+ return "warning";
+ case LogLevels::Error:
+ return "error";
+ default:
+ return "info";
+ }
+}
+
+enum class Progress
+{
+ None = 0,
+ CheckingMasterlistExistence,
+ UpdatingMasterlist,
+ LoadingLists,
+ ReadingPlugins,
+ SortingPlugins,
+ WritingLoadorder,
+ ParsingLootMessages,
+ Done
+};
+
+enum class MessageType
+{
+ None = 0,
+ Progress,
+ Log
+};
+
+struct Message
+{
+ MessageType type = MessageType::None;
+ Progress progress = Progress::None;
+ LogLevels logLevel = LogLevels::Info;
+ std::string log;
+
+ static Message fromProgress(Progress p)
+ {
+ return {MessageType::Progress, p, LogLevels::Info, ""};
+ }
+
+ static Message fromLog(LogLevels level, std::string log)
+ {
+ return {MessageType::Log, Progress::None, level, std::move(log)};
+ }
+};
+
+inline Message parseMessage(const std::string_view& line)
+{
+ static std::regex e(R"(^\[([a-z]+)\] (.+)$)");
+
+ std::match_results<std::string_view::const_iterator> m;
+ if (!std::regex_match(line.begin(), line.end(), m, e)) {
+ return {};
+ }
+
+ const auto type = m[1];
+
+ if (type == "progress") {
+ try {
+ const auto p = std::stoi(m[2]);
+ return Message::fromProgress(static_cast<Progress>(p));
+ } catch (std::exception&) {
+ return {};
+ }
+ } else {
+ return Message::fromLog(logLevelFromString(type), m[2]);
+ }
+}
+
+} // namespace lootcli
+
+#endif // MODORGANIZER_LOOTCLI_INCLUDED