mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-29 04:17:16 +01:00
31 lines
752 B
C++
31 lines
752 B
C++
#include <options.h>
|
|
#include <spdlog/spdlog.h>
|
|
#include <stdlib.h>
|
|
|
|
namespace options {
|
|
CMDLineOptions opts;
|
|
|
|
void loadDefaults() {
|
|
#ifdef _WIN32
|
|
opts.root = ".";
|
|
#else
|
|
std::string homedir = getenv("HOME");
|
|
opts.root = homedir + "/.config/sdrpp";
|
|
#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;
|
|
}
|
|
} |