mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 00:16:22 +01:00
Switch to using getopt_long for config flag
This commit is contained in:
parent
14c949c1c7
commit
7b91712416
1 changed files with 10 additions and 7 deletions
|
@ -789,13 +789,16 @@ int main(int argc, char **argv) {
|
||||||
wlr_log_init(WLR_DEBUG, NULL);
|
wlr_log_init(WLR_DEBUG, NULL);
|
||||||
|
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
for (int i = 0; i < argc; i++) {
|
static struct option long_options[] = {
|
||||||
if (strcmp(argv[i], "-C") == 0 || strcmp(argv[i], "--config") == 0) {
|
{"config", required_argument, NULL, 'C'},
|
||||||
if (i + 1 == argc) {
|
{0, 0, 0, 0},
|
||||||
wlr_log(WLR_ERROR, "Config file path is missing");
|
};
|
||||||
return 1;
|
while (1) {
|
||||||
}
|
int c = getopt_long(argc, argv, "C:", long_options, NULL);
|
||||||
config_path = strdup(argv[i + 1]);
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
} else if (c == 'C') {
|
||||||
|
config_path = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue