feat: return an error if the next argument after -c is a flag

This commit is contained in:
Eduard Tykhoniuk 2024-09-24 13:33:52 +02:00
parent f60bff7e3d
commit 4e336530d3

View file

@ -17,11 +17,15 @@ int main(int argc, char** argv, char** envp) {
else if (arg == "--config" || arg == "-c") {
if (i + 1 >= argc) {
Debug::log(NONE, "Please provide a path to a config file.");
Debug::log(NONE, "After " + arg + " you should provide a path to a config file.");
return 1;
}
configPath = argv[++i];
if (configPath[0] == '-') { // Should be fine, because of the null terminator
Debug::log(NONE, "After " + arg + " you should provide a path to a config file.");
return 1;
}
}
}