diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-11 10:33:47 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-11 10:33:47 -0800 |
commit | 981dfdb23272bc02977c5bb9bc18d0d3fb618fa3 (patch) | |
tree | 299cfbe0d0a91b23039fc61d9dee14b23539ff93 /xedit.c | |
parent | 13cef251511816a9b1b20675800ae6da3e1ff4c6 (diff) |
Add -help and -version options
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xedit.c')
-rw-r--r-- | xedit.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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); |