mirror of
https://github.com/hyprwm/hypridle.git
synced 2024-12-22 05:29:49 +01:00
core: Do not crash if the last CLI parameter was -c (#92)
* fix: Do not crash if the last CLI parameter was -c * feat: return an error if the next argument after -c is a flag * feat: return an error if multiple config files are provided
This commit is contained in:
parent
22b058b47a
commit
cc23f97836
1 changed files with 14 additions and 0 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -16,7 +16,21 @@ int main(int argc, char** argv, char** envp) {
|
||||||
Debug::quiet = true;
|
Debug::quiet = true;
|
||||||
|
|
||||||
else if (arg == "--config" || arg == "-c") {
|
else if (arg == "--config" || arg == "-c") {
|
||||||
|
if (i + 1 >= argc) {
|
||||||
|
Debug::log(NONE, "After " + arg + " you should provide a path to a config file.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!configPath.empty()) {
|
||||||
|
Debug::log(NONE, "Multiple config files are provided.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
configPath = argv[++i];
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue