|
6 | 6 | #include <vector>
|
7 | 7 | #include <string>
|
8 | 8 |
|
9 |
| -// Updated parseCSV to take a multiplier |
| 9 | + |
10 | 10 | std::vector<ChatMessage> parseCSV(const std::string &filename, int timeMultiplier) {
|
11 | 11 | std::vector<ChatMessage> messages;
|
12 | 12 | try {
|
13 | 13 | csv::CSVReader reader(filename);
|
14 |
| - for (auto &row : reader) { |
| 14 | + for (auto &row: reader) { |
15 | 15 | ChatMessage msg;
|
16 | 16 | msg.time = row["time"].get<int>() * timeMultiplier;
|
17 | 17 |
|
@@ -49,33 +49,28 @@ int main(int argc, char *argv[]) {
|
49 | 49 | ->check(CLI::ExistingFile);
|
50 | 50 | app.add_option("-o,--output", outputPath, "Output file (e.g. output.srv3 or output.ytt)")
|
51 | 51 | ->required();
|
52 |
| - app.add_option("-u,--time-unit", timeUnit,"Time unit inside CSV: “ms” or “sec”") |
53 |
| - ->required() |
54 |
| - ->check(CLI::IsMember({"ms","sec"}, CLI::ignore_case)); |
| 52 | + app.add_option("-u,--time-unit", timeUnit, "Time unit inside CSV: “ms” or “sec”") |
| 53 | + ->required() |
| 54 | + ->check(CLI::IsMember({"ms", "sec"}, CLI::ignore_case)); |
55 | 55 |
|
56 | 56 | CLI11_PARSE(app, argc, argv);
|
57 | 57 |
|
58 |
| - // Determine multiplier from timeUnit |
59 | 58 | int multiplier = (timeUnit == "sec") ? 1000 : 1;
|
60 | 59 |
|
61 |
| - // Load config |
62 | 60 | ChatParams params;
|
63 | 61 | if (!params.loadFromFile(configPath.c_str())) {
|
64 | 62 | std::cerr << "Error: Cannot open config file: " << configPath << "\n";
|
65 | 63 | return 1;
|
66 | 64 | }
|
67 | 65 |
|
68 |
| - // Parse CSV with correct time multiplier |
69 | 66 | auto chat = parseCSV(csvPath, multiplier);
|
70 | 67 | if (chat.empty()) {
|
71 | 68 | std::cerr << "Error: Failed to parse chat CSV or it's empty: " << csvPath << "\n";
|
72 | 69 | return 1;
|
73 | 70 | }
|
74 | 71 |
|
75 |
| - // Generate XML |
76 | 72 | std::string xml = generateXML(chat, params);
|
77 | 73 |
|
78 |
| - // Write to output |
79 | 74 | std::ofstream out(outputPath);
|
80 | 75 | if (!out) {
|
81 | 76 | std::cerr << "Error: Cannot open output file: " << outputPath << "\n";
|
|
0 commit comments