diff options
| author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-16 12:17:16 -0400 |
|---|---|---|
| committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-16 12:17:40 -0400 |
| commit | 2bb424ea894cf9ee9bed4b086ee60feee7ed6a30 (patch) | |
| tree | 47fdb9e421b0abc020c8c9d1edae4550834d76fc /main.c | |
| parent | 96af98e9769166f672e9ef54d9387d0630ba1646 (diff) | |
Switch to using getopt_long for config flag
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -789,13 +789,16 @@ int main(int argc, char **argv) { wlr_log_init(WLR_DEBUG, NULL); char *config_path = NULL; - for (int i = 0; i < argc; i++) { - if (strcmp(argv[i], "-C") == 0 || strcmp(argv[i], "--config") == 0) { - if (i + 1 == argc) { - wlr_log(WLR_ERROR, "Config file path is missing"); - return 1; - } - config_path = strdup(argv[i + 1]); + static struct option long_options[] = { + {"config", required_argument, NULL, 'C'}, + {0, 0, 0, 0}, + }; + while (1) { + int c = getopt_long(argc, argv, "C:", long_options, NULL); + if (c == -1) { + break; + } else if (c == 'C') { + config_path = strdup(optarg); break; } } |
