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 | 7b91712416953c25f2722fedb57b474504460a48 (patch) | |
tree | 8387d2550524394e1ac7275ac040a355f2a4bfbf | |
parent | Remove leftover parens (diff) | |
download | sway-7b91712416953c25f2722fedb57b474504460a48.tar.gz sway-7b91712416953c25f2722fedb57b474504460a48.tar.zst sway-7b91712416953c25f2722fedb57b474504460a48.zip |
Switch to using getopt_long for config flag
-rw-r--r-- | swaylock/main.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index 4ca53b84..ae5b86b9 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -789,13 +789,16 @@ int main(int argc, char **argv) { | |||
789 | wlr_log_init(WLR_DEBUG, NULL); | 789 | wlr_log_init(WLR_DEBUG, NULL); |
790 | 790 | ||
791 | char *config_path = NULL; | 791 | char *config_path = NULL; |
792 | for (int i = 0; i < argc; i++) { | 792 | static struct option long_options[] = { |
793 | if (strcmp(argv[i], "-C") == 0 || strcmp(argv[i], "--config") == 0) { | 793 | {"config", required_argument, NULL, 'C'}, |
794 | if (i + 1 == argc) { | 794 | {0, 0, 0, 0}, |
795 | wlr_log(WLR_ERROR, "Config file path is missing"); | 795 | }; |
796 | return 1; | 796 | while (1) { |
797 | } | 797 | int c = getopt_long(argc, argv, "C:", long_options, NULL); |
798 | config_path = strdup(argv[i + 1]); | 798 | if (c == -1) { |
799 | break; | ||
800 | } else if (c == 'C') { | ||
801 | config_path = strdup(optarg); | ||
799 | break; | 802 | break; |
800 | } | 803 | } |
801 | } | 804 | } |