]> git.armaanb.net Git - mmenu.git/commitdiff
Add usage message and clean up exit codes
authorArmaan Bhojwani <me@armaanb.net>
Sun, 9 May 2021 20:03:40 +0000 (16:03 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 9 May 2021 20:12:21 +0000 (16:12 -0400)
mmenu.1.scd
mmenu.c

index 11bbcd9bade1e9af2bc6e43e4c60d9fb28d261ec..d7abf1b7e58e29e033d2da0e7c876ea9af87979d 100644 (file)
@@ -10,5 +10,11 @@ mmenu - view the Castle menu
 The *mmenu* utility uses Nobilis in order to display the castle menu. There is
 no real command line interface, and the GUI is programmed in Motif.
 
+# EXIT CODES
+*0*    all ok,++
+*1*    libcurl/page request error,++
+*2*    out of memory,++
+*3*    usage error
+
 # LICENSE
 MIT License, Armaan Bhojwani 2021.
diff --git a/mmenu.c b/mmenu.c
index 4e4283ca7bb5c555bc212303aede7819ec07ad05..01a89637c6b3e9ae40bf6805eb268098101dd7b3 100644 (file)
--- a/mmenu.c
+++ b/mmenu.c
@@ -20,7 +20,7 @@ int
 memfail(void)
 {
        printf("ERROR: Out of memory\n");
-       exit(4);
+       exit(2);
 }
 
 static size_t
@@ -73,7 +73,7 @@ getmenu(char *date)
        if (res != CURLE_OK) {
                fprintf(stderr,"ERROR: Could not fetch webpage\n%s\n",
                                                curl_easy_strerror(res));
-               exit(2);
+               exit(1);
        }
 
        curl_easy_cleanup(curl);
@@ -153,6 +153,11 @@ XmStringTable ArgvToXmStringTable (int argc, char **argv)
 int
 main(int argc, char *argv[])
 {
+       if (argc > 1) {
+               printf("Usage: %s\n", argv[0]);
+               exit(3);
+       }
+
        // Initialize motif
        Widget         toplevel, rowcol, daysel, disp;
        XmStringTable  strs;