aboutsummaryrefslogtreecommitdiffstats
path: root/mpd-notification.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2015-07-03 12:53:48 +0200
committerGravatar Christian Hesse <mail@eworm.de>2015-07-03 12:53:48 +0200
commit02a7441b621db03161061dbfd5a93f1a1adc7e75 (patch)
tree01ffeef3e9fb31b83a7e468f14200f69d1e0a463 /mpd-notification.c
parente05895b91478c80cd221785063da73c64fc89a18 (diff)
downloadmpd-notification-02a7441b621db03161061dbfd5a93f1a1adc7e75.tar.gz
mpd-notification-02a7441b621db03161061dbfd5a93f1a1adc7e75.tar.zst
add --version option
Diffstat (limited to 'mpd-notification.c')
-rw-r--r--mpd-notification.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/mpd-notification.c b/mpd-notification.c
index 65dc332..764df95 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -7,7 +7,7 @@
#include "mpd-notification.h"
-const static char optstring[] = "hH:m:p:t:v";
+const static char optstring[] = "hH:m:p:t:vV";
const static struct option options_long[] = {
/* name has_arg flag val */
{ "help", no_argument, NULL, 'h' },
@@ -16,6 +16,7 @@ const static struct option options_long[] = {
{ "port", required_argument, NULL, 'p' },
{ "timeout", required_argument, NULL, 't' },
{ "verbose", no_argument, NULL, 'v' },
+ { "version", no_argument, NULL, 'V' },
{ 0, 0, 0, 0 }
};
@@ -169,7 +170,7 @@ int main(int argc, char ** argv) {
const char * mpd_host = MPD_HOST, * music_dir = NULL, * uri = NULL;
unsigned mpd_port = MPD_PORT, mpd_timeout = MPD_TIMEOUT, notification_timeout = NOTIFICATION_TIMEOUT;
struct mpd_song * song = NULL;
- unsigned int i;
+ unsigned int i, version = 0, help = 0;
program = argv[0];
@@ -178,9 +179,16 @@ int main(int argc, char ** argv) {
/* get the verbose status */
while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) {
switch (i) {
+ case 'h':
+ help++;
+ break;
case 'v':
verbose++;
break;
+ case 'V':
+ verbose++;
+ version++;
+ break;
}
}
@@ -191,12 +199,15 @@ int main(int argc, char ** argv) {
if (verbose > 0)
printf("%s: %s v%s (compiled: " __DATE__ ", " __TIME__ ")\n", program, PROGNAME, VERSION);
+ if (help > 0)
+ fprintf(stderr, "usage: %s [-h] [-H HOST] [-p PORT] [-m MUSIC-DIR] [-t TIMEOUT] [-v] [-V]\n", program);
+
+ if (version > 0 || help > 0)
+ return EXIT_SUCCESS;
+
/* get command line options */
while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) {
switch (i) {
- case 'h':
- fprintf(stderr, "usage: %s [-h] [-H HOST] [-p PORT] [-m MUSIC-DIR] [-t TIMEOUT] [-v]\n", program);
- return EXIT_SUCCESS;
case 'p':
mpd_port = atoi(optarg);
if (verbose > 0)