summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-11 10:33:47 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-11 10:33:47 -0800
commit981dfdb23272bc02977c5bb9bc18d0d3fb618fa3 (patch)
tree299cfbe0d0a91b23039fc61d9dee14b23539ff93
parent13cef251511816a9b1b20675800ae6da3e1ff4c6 (diff)
Add -help and -version options
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xedit.c23
1 files changed, 23 insertions, 0 deletions
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 <X11/Xaw/SmeBSB.h>
#include <time.h>
@@ -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);