summaryrefslogtreecommitdiff
path: root/xfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'xfd.c')
-rw-r--r--xfd.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/xfd.c b/xfd.c
index 8108d19..4a12381 100644
--- a/xfd.c
+++ b/xfd.c
@@ -70,7 +70,7 @@ static XrmOptionDescRec xfd_options[] = {
{"-columns", "*grid.cellColumns", XrmoptionSepArg, (caddr_t) NULL },
};
-static void usage(void) _X_NORETURN _X_COLD;
+static void usage(int exitval) _X_NORETURN _X_COLD;
static void SelectChar(Widget w, XtPointer closure, XtPointer data);
static void do_quit(Widget w, XEvent *event, String *params,
Cardinal *num_params) _X_NORETURN;
@@ -134,7 +134,7 @@ static XtResource Resources[] = {
#undef Offset
static void
-usage(void)
+usage(int exitval)
{
fprintf (stderr, gettext("usage: %s [-options ...] "), ProgramName);
fprintf (stderr, "-fn ");
@@ -161,7 +161,7 @@ usage(void)
fprintf (stderr, gettext("number number of rows in grid\n"));
fprintf (stderr, " -columns ");
fprintf (stderr, gettext("number number of columns in grid\n"));
- exit (1);
+ exit (exitval);
}
@@ -190,6 +190,22 @@ main(int argc, char *argv[])
ProgramName = argv[0];
+ /* 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 -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);
+ }
+ }
+
toplevel = XtAppInitialize (&xtcontext, "Xfd",
xfd_options, XtNumber(xfd_options),
&argc, argv, NULL, NULL, 0);
@@ -200,7 +216,7 @@ main(int argc, char *argv[])
fprintf(stderr, " %s", argv[n]);
}
fputs("\n\n", stderr);
- usage ();
+ usage (1);
}
#ifdef USE_GETTEXT