From 981dfdb23272bc02977c5bb9bc18d0d3fb618fa3 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 11 Feb 2023 10:33:47 -0800 Subject: Add -help and -version options Signed-off-by: Alan Coopersmith --- xedit.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'xedit.c') diff --git a/xedit.c b/xedit.c index f7a8b68..77c6bdc 100644 --- a/xedit.c +++ b/xedit.c @@ -26,6 +26,10 @@ */ /* $XFree86: xc/programs/xedit/xedit.c,v 1.17 2002/09/22 07:09:05 paulo Exp $ */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "xedit.h" #include #include @@ -131,6 +135,25 @@ main(int argc, char *argv[]) show_dir = FALSE; first_item = 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) { + fprintf(stderr, + "usage: %s [-toolkitoption] [-help] [-version] [filename...]\n", + argv[0]); + exit(0); + } + if (strcmp(argn, "-version") == 0) { + puts(PACKAGE_STRING); + exit(0); + } + } + topwindow = XtAppInitialize(&appcon, "Xedit", NULL, 0, &argc, argv, NULL, NULL, 0); -- cgit v1.2.3