2020-12-15 23:05:11 +01:00
|
|
|
#include <options.h>
|
2020-12-22 14:50:26 +01:00
|
|
|
#include <spdlog/spdlog.h>
|
2020-12-15 23:05:11 +01:00
|
|
|
|
|
|
|
namespace options {
|
2020-12-22 14:50:26 +01:00
|
|
|
CMDLineOptions opts;
|
|
|
|
|
|
|
|
void loadDefaults() {
|
|
|
|
#ifdef _WIN32
|
|
|
|
opts.root = ".";
|
|
|
|
#else
|
2020-12-22 22:39:24 +01:00
|
|
|
opts.root = "~/.config/sdrpp";
|
2020-12-22 14:50:26 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool parse(int argc, char *argv[]) {
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
char* arg = argv[i];
|
|
|
|
if (!strcmp(arg, "-r") || !strcmp(arg, "--root")) {
|
|
|
|
if (i == argc - 1) { return false; }
|
|
|
|
opts.root = argv[++i];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
spdlog::error("Invalid command line option: {0}", arg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2020-12-15 23:05:11 +01:00
|
|
|
}
|
|
|
|
}
|