]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/rain.c
ncurses 6.3 - patch 20221203
[ncurses.git] / test / rain.c
index dde411b2b3e43cf000e6cfb363fb8be808115f60..1b1d81a05bcbc0b2ffc37f3b67cf1a49e2347687 100644 (file)
@@ -27,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: rain.c,v 1.54 2022/07/23 22:47:38 tom Exp $
+ * $Id: rain.c,v 1.57 2022/12/04 00:40:11 tom Exp $
  */
 #include <test.priv.h>
 #include <popup_msg.h>
@@ -302,12 +302,13 @@ get_input(void)
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
        "Usage: rain [options]"
        ,""
+       ,USAGE_COMMON
        ,"Options:"
 #if HAVE_USE_DEFAULT_COLORS
        ," -d       invoke use_default_colors"
@@ -318,8 +319,11 @@ usage(void)
     for (n = 0; n < SIZEOF(msg); n++)
        fprintf(stderr, "%s\n", msg[n]);
 
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
@@ -345,20 +349,23 @@ main(int argc, char *argv[])
     bool d_option = FALSE;
 #endif
 
-    while ((ch = getopt(argc, argv, "d")) != -1) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "d")) != -1) {
        switch (ch) {
 #if HAVE_USE_DEFAULT_COLORS
        case 'd':
            d_option = TRUE;
            break;
 #endif
+       case OPTS_VERSION:
+           show_version(argv);
+           ExitProgram(EXIT_SUCCESS);
        default:
-           usage();
+           usage(ch == OPTS_USAGE);
            /* NOTREACHED */
        }
     }
     if (optind < argc)
-       usage();
+       usage(FALSE);
 
     setlocale(LC_ALL, "");