From a3ceb7051449635f448be7a9ab54de6977321896 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 27 Jan 2008 01:34:37 +0100 Subject: [PATCH] Add --(help|version) to awmessage --- awesome-message.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/awesome-message.c b/awesome-message.c index 05458ce..0a13a09 100644 --- a/awesome-message.c +++ b/awesome-message.c @@ -19,6 +19,8 @@ * */ +#define _GNU_SOURCE +#include #include #include #include @@ -49,13 +51,25 @@ main(int argc, char **argv) int opt; Area geometry = { 0, 0, 200, 50 }, icon_geometry = { -1, -1, -1, -1 }; XftFont *font = NULL; + int option_index = 0; + static struct option long_options[] = { + {"help", 0, NULL, 0}, + {"version", 0, NULL, 0}, + {NULL, 0, NULL, 0} + }; if(!(disp = XOpenDisplay(NULL))) eprint("unable to open display"); - while((opt = getopt(argc, argv, "vhf:b:x:y:n:")) != -1) + while((opt = getopt_long(argc, argv, "vhf:b:x:y:n:", + long_options, &option_index)) != -1) switch(opt) { + case 0: + if (!a_strcmp("help", long_options[option_index].name)) + exit_help(EXIT_SUCCESS); + else if (!a_strcmp("version", long_options[option_index].name)) + eprint_version("awmessage"); case 'v': eprint_version("awmessage"); break; @@ -87,7 +101,7 @@ main(int argc, char **argv) geometry.width = draw_textwidth(disp, font, argv[optind]); geometry.height = font->height * 1.5; - + if(argc - optind >= 2) { icon_geometry = draw_get_image_size(argv[optind + 1]); -- 1.5.3.7