diff options
author | marchersimon | 2021-06-06 14:07:07 +0200 |
---|---|---|
committer | Mistyhands | 2023-06-16 00:48:17 +0100 |
commit | 4ee051d5da7057d2a3c5bf7d8202e39e04802679 (patch) | |
tree | c979e93a74722ab3aa0f7fd98acd324c25a5a088 | |
parent | cdbdaa7bbb02266e0d4ad43bf5c161867cb21186 (diff) | |
download | aur-4ee051d5da7057d2a3c5bf7d8202e39e04802679.tar.gz |
add long options
-rw-r--r-- | main.c | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -22,8 +22,13 @@ #include <X11/cursorfont.h> #include <X11/Xutil.h> -#include <unistd.h> #include <stdio.h> +#include <getopt.h> + +/* +static struct option long_options[] = { + {"oneshot", no_argument, } + };*/ int main(int argc, char *argv[]) { @@ -31,7 +36,16 @@ int main(int argc, char *argv[]) { int one_shot = 0; int quit_on_keypress = 0; int output_format = 0x11; - while ((opt = getopt(argc, argv, "oqhrd")) != -1) { + + static struct option long_options[] = { + {"oneshot", no_argument, NULL, 'o'}, + {"quit-on-keypress", no_argument, NULL, 'q'}, + {"help", no_argument, NULL, 'h'}, + {"rgb", no_argument, NULL, 'r'}, + {"hex", no_argument, NULL, 'd'} + }; + + while ((opt = getopt_long(argc, argv, "oqhrd", long_options, NULL)) != -1) { switch(opt) { case 'o': one_shot = 1; @@ -47,11 +61,11 @@ int main(int argc, char *argv[]) { break; case 'h': printf( "colorpicker [options]\n" - " -h: show this help\n" - " -o: oneshot\n" - " -q: quit on keypress\n" - " -d: hex only\n" - " -r: rgb only\n"); + " -h, --help: show this help\n" + " -o, --one-shot: oneshot\n" + " -q, --quit-on-keypress: quit on keypress\n" + " -d, --hex: hex only\n" + " -r, --rgb: rgb only\n"); return 0; default: return 1; |