mirror of
https://github.com/Mr-Wiseguy/N64Recomp.git
synced 2025-12-05 01:10:45 +00:00
Make arg parsing more generic and fix running with no args
This commit is contained in:
26
src/main.cpp
26
src/main.cpp
@@ -272,22 +272,26 @@ int main(int argc, char** argv) {
|
||||
std::exit(EXIT_FAILURE);
|
||||
};
|
||||
|
||||
bool dumping_context;
|
||||
bool dumping_context = false;
|
||||
|
||||
if (argc >= 3) {
|
||||
std::string arg2 = argv[2];
|
||||
if (arg2 == "--dump-context") {
|
||||
dumping_context = true;
|
||||
} else {
|
||||
fmt::print("Usage: {} <config file> [--dump-context]\n", argv[0]);
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
} else {
|
||||
dumping_context = false;
|
||||
if (argc < 2) {
|
||||
fmt::print("Usage: {} <config file> [--dump-context]\n", argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
const char* config_path = argv[1];
|
||||
|
||||
for (size_t i = 2; i < argc; i++) {
|
||||
std::string_view cur_arg = argv[i];
|
||||
if (cur_arg == "--dump-context") {
|
||||
dumping_context = true;
|
||||
}
|
||||
else {
|
||||
fmt::print("Unknown argument \"{}\"\n", cur_arg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
N64Recomp::Config config{ config_path };
|
||||
if (!config.good()) {
|
||||
exit_failure(fmt::format("Failed to load config file: {}\n", config_path));
|
||||
|
||||
Reference in New Issue
Block a user