-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectie4k.cpp
More file actions
71 lines (58 loc) · 2.11 KB
/
projectie4k.cpp
File metadata and controls
71 lines (58 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <string>
#include "core/CFG.h"
#include "core/GlobalContext.h"
#include "core/Logging/Logging.h"
#include "plugins/CommandRegistry.h"
#include "plugins/PluginManager.h"
#include "services/ServiceManager.h"
using namespace std::filesystem;
using namespace ProjectIE4k;
int main(int argc, char **argv) {
std::string configFile;
// Manual scan for -c anywhere (other flags handled by GlobalContext)
for (int i = 1; i < argc; ++i) {
std::string_view a = argv[i];
if (a == "-c" && i + 1 < argc) {
configFile = argv[i + 1];
++i;
continue;
}
if (a.rfind("-c=", 0) == 0 && a.size() > 3) {
configFile = std::string(a.substr(3));
continue;
}
}
// Auto-detect config file if not specified
if (configFile.empty()) {
configFile = PIE4K_CFG.findConfigFile();
if (configFile.empty()) {
std::cerr << "Error: No config file specified with -c and no .cfg file found in current directory" << std::endl;
return 1;
}
}
// Initialize command registry for help or execution
CommandTable commandTable;
PluginManager::getInstance().registerAllCommands(commandTable);
ServiceManager::registerCommands(commandTable);
// Show help if no command specified
if (argc <= 1) {
printHelp(commandTable, argv[0]);
return 0;
}
InitializeLogging();
// Initialize ProjectIE4k CFG
PIE4K_CFG.initialize(configFile);
ToggleLogging(PIE4K_CFG.Logging);
Log(MESSAGE, "Core", "Project IE 4K using GamePath: {}", PIE4K_CFG.GamePath);
// Trigger application start lifecycle and register context providers
ServiceManager::onApplicationStart();
// Parse all registered context providers (after logging is initialized)
GlobalContext::getInstance().parseAll(argc, argv);
int result = prepareCommands(commandTable, argc, argv);
// Trigger application shutdown lifecycle
ServiceManager::onApplicationShutdown();
// Shutdown our logging system
ShutdownLogging();
return result;
}