]> Pileus Git - lackey/blobdiff - src/args.c
Add simple notification daemon mode
[lackey] / src / args.c
index 49fe2f104ace9edd92180ac5ae20137df57f0c46..0390e0fa0a7b2e0bd0ba28a0da86c69f425e94b4 100644 (file)
@@ -26,6 +26,7 @@
 
 /* Global data */
 int PRINT  = 0;
+int DAEMON = 0;
 
 /* Local data */
 char **calendars = NULL;
@@ -36,6 +37,7 @@ static char *short_options = "hp::d";
 struct option long_options[] = {
        {"help",   0, NULL, 'h'},
        {"print",  2, NULL, 'p'},
+       {"daemon", 0, NULL, 'd'},
 };
 
 /* Usage */
@@ -47,6 +49,7 @@ static void usage(char *name)
        printf("Options:\n");
        printf("  -h, --help        Print usage information\n");
        printf("  -p, --print=[dw]  Show upcomming events\n");
+       printf("  -d, --daemon      Run in daemon mode\n");
 }
 
 /* Initialize */
@@ -70,6 +73,9 @@ void args_setup(int argc, char **argv)
                                        match(optarg, "w")    ? 7 :
                                        match(optarg, "week") ? 7 : -1;
                                break;
+                       case 'd':
+                               DAEMON = 1;
+                               break;
                }
        }
 
@@ -79,6 +85,8 @@ void args_setup(int argc, char **argv)
        /* Validate arguments */
        if (PRINT < 0)
                error("Unknown print: %s\n", optarg);
+       if (PRINT && DAEMON)
+               error("Cannot print and run as daemon");
 
        /* Load calendars */
        for (int i = 0; calendars[i]; i++)