diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 11:34:18 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 11:38:29 -0800 |
commit | 0f9f41f177b4713a6792a2bc87dfbb186b8926bd (patch) | |
tree | 5323e07c37f5ac93b5018cf13b46d3c3247de2fb /xbiff.c | |
parent | 44cc442a633a3ce39603fc879793a4f51b6ae132 (diff) |
Add -help option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xbiff.c')
-rw-r--r-- | xbiff.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -68,7 +68,8 @@ static XtActionsRec xbiff_actions[] = { { "quit", quit }, }; -static void Usage (void) +static void _X_NORETURN _X_COLD +Usage (int exitval) { const char *help_message = "where options include:\n" @@ -81,11 +82,12 @@ static void Usage (void) " -fg color foreground color\n" " -rv reverse video\n" " -shape shape the window\n" +" -help print usage info and exit\n" " -version print version info and exit\n"; fprintf (stderr, "usage: %s [-options ...]\n", ProgramName); fprintf (stderr, "%s\n", help_message); - exit (1); + exit (exitval); } @@ -102,10 +104,13 @@ main (int argc, char **argv) /* Handle args that don't require opening a display */ for (int n = 1; n < argc; n++) { const char *argn = argv[n]; - /* accept single or double dash for -version */ + /* accept single or double dash for -help & -version */ if (argn[0] == '-' && argn[1] == '-') { argn++; } + if (strcmp(argn, "-help") == 0) { + Usage(0); + } if (strcmp(argn, "-version") == 0) { puts(PACKAGE_STRING); exit(0); @@ -114,7 +119,9 @@ main (int argc, char **argv) toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options), &argc, argv, NULL, NULL, 0); - if (argc != 1) Usage (); + if (argc != 1) { + Usage(1); + } /* * This is a hack so that f.delete will do something useful in this |