summaryrefslogtreecommitdiff
path: root/xfontsel.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-11 11:27:51 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-11 11:27:51 -0800
commit48772e02a3067fb8450b98ddde5e1fed7a6ce80e (patch)
treecd5409ad5c72bac22ae52d4b896e1abb5c7779c3 /xfontsel.c
parente7c9e106e65767598b786804dc7324adc50d7efc (diff)
Add -help and -version options
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xfontsel.c')
-rw-r--r--xfontsel.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/xfontsel.c b/xfontsel.c
index 653d532..400eb09 100644
--- a/xfontsel.c
+++ b/xfontsel.c
@@ -187,7 +187,7 @@ static XrmOptionDescRec options[] = {
{"-scaled", "scaledFonts", XrmoptionNoArg, "True"},
};
-static void Syntax(const char *call)
+static void Syntax(const char *call, int exitval)
{
fprintf (stderr, "usage: %s [-options ...] -fn font\n\n%s\n", call,
gettext(
@@ -201,7 +201,7 @@ static void Syntax(const char *call)
" -sampleUCS string sample text to use for ISO10646 fonts\n"
" -scaled use scaled instances of fonts\n"
"plus any standard toolkit options\n"));
- exit (1);
+ exit (exitval);
}
@@ -297,6 +297,22 @@ main(int argc, char **argv)
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
+ /* 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) {
+ Syntax(argv[0], 0);
+ }
+ if (strcmp(argn, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ }
+
topLevel = XtAppInitialize(&appCtx, "XFontSel", options, XtNumber(options),
&argc, argv, NULL, NULL, 0);
@@ -325,7 +341,7 @@ main(int argc, char **argv)
fprintf(stderr, " %s", argv[n]);
}
fputs("\n\n", stderr);
- Syntax(argv[0]);
+ Syntax(argv[0], 1);
}
XtAppAddActions(appCtx, xfontsel_actions, XtNumber(xfontsel_actions));