mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
core: minor refactor of command line options parsing (#441)
This commit is contained in:
parent
cf0e975fed
commit
5e8f12c2d9
1 changed files with 10 additions and 14 deletions
24
src/main.cpp
24
src/main.cpp
|
@ -11,9 +11,10 @@ void help() {
|
|||
" -v, --verbose - Enable verbose logging\n"
|
||||
" -q, --quiet - Disable logging\n"
|
||||
" -c FILE, --config FILE - Specify config file to use\n"
|
||||
" --display (display) - Specify the Wayland display to connect to\n"
|
||||
" --display NAME - Specify the Wayland display to connect to\n"
|
||||
" --immediate - Lock immediately, ignoring any configured grace period\n"
|
||||
" --immediate-render - Do not wait for resources before drawing the background\n"
|
||||
" -V, --version - Show version information\n"
|
||||
" -h, --help - Show this help message\n";
|
||||
}
|
||||
|
||||
|
@ -31,21 +32,25 @@ int main(int argc, char** argv, char** envp) {
|
|||
std::string wlDisplay;
|
||||
bool immediate = false;
|
||||
bool immediateRender = false;
|
||||
bool showHelp = false;
|
||||
|
||||
std::vector<std::string> args(argv, argv + argc);
|
||||
|
||||
for (std::size_t i = 1; i < args.size(); ++i) {
|
||||
const std::string arg = argv[i];
|
||||
|
||||
if (arg == "--verbose" || arg == "-v")
|
||||
Debug::verbose = true;
|
||||
if (arg == "--help" || arg == "-h") {
|
||||
help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg == "--version" || arg == "-V") {
|
||||
std::cout << "Hyprlock version " << HYPRLOCK_VERSION << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg == "--verbose" || arg == "-v")
|
||||
Debug::verbose = true;
|
||||
|
||||
else if (arg == "--quiet" || arg == "-q")
|
||||
Debug::quiet = true;
|
||||
|
||||
|
@ -67,22 +72,13 @@ int main(int argc, char** argv, char** envp) {
|
|||
else if (arg == "--immediate-render")
|
||||
immediateRender = true;
|
||||
|
||||
else if (arg == "--help" || arg == "-h") {
|
||||
showHelp = true;
|
||||
break;
|
||||
|
||||
} else {
|
||||
else {
|
||||
std::cerr << "Unknown option: " << arg << "\n";
|
||||
help();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (showHelp) {
|
||||
help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
g_pConfigManager = std::make_unique<CConfigManager>(configPath);
|
||||
g_pConfigManager->init();
|
||||
|
|
Loading…
Reference in a new issue