diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2024-06-20 08:11:38 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2024-06-20 08:11:38 +0000 |
commit | 24fa7a5107c5b75d1c197accf0305be64bc72882 (patch) | |
tree | 183f09c93417ac0e5f7f49760329a3d2cfaacda9 /test/newdemo.c | |
parent | bf0ab54638a5ef969749f6ceae30e864f9556ea8 (diff) |
Diffstat (limited to 'test/newdemo.c')
-rw-r--r-- | test/newdemo.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/test/newdemo.c b/test/newdemo.c index d76523ab6ffd..78761534d7c5 100644 --- a/test/newdemo.c +++ b/test/newdemo.c @@ -2,7 +2,7 @@ * newdemo.c - A demo program using PDCurses. The program illustrate * the use of colours for text output. * - * $Id: newdemo.c,v 1.47 2019/12/14 23:25:29 tom Exp $ + * $Id: newdemo.c,v 1.48 2022/12/10 23:36:05 tom Exp $ */ #include <test.priv.h> @@ -215,17 +215,51 @@ BouncingBalls(WINDOW *win) return 0; } +static void +usage(int ok) +{ + static const char *msg[] = + { + "Usage: newdemo [options]" + ,"" + ,USAGE_COMMON + }; + size_t n; + + for (n = 0; n < SIZEOF(msg); n++) + fprintf(stderr, "%s\n", msg[n]); + + ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE); +} +/* *INDENT-OFF* */ +VERSION_COMMON() +/* *INDENT-ON* */ + /* * Main driver */ int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +main(int argc, char *argv[]) { WINDOW *win; int x, y, i, k; char buffer[SIZEOF(messages) * 80]; int width, height; chtype save[80]; + int ch; + + while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) { + switch (ch) { + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); + default: + usage(ch == OPTS_USAGE); + /* NOTREACHED */ + } + } + if (optind < argc) + usage(FALSE); setlocale(LC_ALL, ""); |