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
72
73
|
#include <iostream>
#include "CLI11.hpp"
#include "Companion.h"
#ifdef STANDALONE
Companion* Companion::Instance;
int main(int argc, char *argv[]) {
CLI::App app{"Torch - [T]orch is [O]ur [R]esource [C]onversion [H]elper\n\
* It extracts from a baserom and generates code or an otr.\n\
* It can also generate an otr from a folder of assets.\n"
};
std::string mode;
std::string filename;
std::string target;
std::string folder;
bool otrMode = false;
bool debug = false;
bool header = false;
app.require_subcommand();
/* Generate an OTR */
auto otr = app.add_subcommand("otr", "OTR - Generates an otr\n");
otr->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile);
otr->add_flag("-t,--target", target, "OTR output destination");
otr->add_flag("-o,--otr", otrMode, "OTR Mode");
otr->add_flag("-d,--dir", folder, "Generate OTR from a directory of assets");
otr->add_flag("-z,--zeader", header, "Generates a header");
otr->add_flag("-v,--verbose", debug, "Verbose Debug Mode");
otr->parse_complete_callback([&]() {
auto instance = Companion::Instance = new Companion(filename, otrMode, debug);
if (header) {
instance->Init(ExportType::Header);
} else {
instance->Init(ExportType::Binary);
}
if (!folder.empty()) {
Companion::Pack(folder, target);
}
});
/* Generate C code */
auto code = app.add_subcommand("code", "Code - Generates C code\n");
code->add_option("<baserom.z64>", filename, "")->required()->check(CLI::ExistingFile);
code->add_flag("-v,--verbose", debug, "Verbose Debug Mode; adds offsets to C code");
code->parse_complete_callback([&]() {
auto instance = Companion::Instance = new Companion(filename, otrMode, debug);
instance->Init(ExportType::Code);
});
try {
app.parse(argc, argv);
} catch (const CLI::ParseError &e) {
std::cout << app.help() << std::endl;
return app.exit(e);
}
// No arguments --> display help.
if (argc == 1) {
std::cout << app.help() << std::endl;
}
return 0;
}
#endif
|