summaryrefslogtreecommitdiff
path: root/xkbwatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'xkbwatch.c')
-rw-r--r--xkbwatch.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/xkbwatch.c b/xkbwatch.c
index 0502a15..68d1cbb 100644
--- a/xkbwatch.c
+++ b/xkbwatch.c
@@ -78,11 +78,27 @@ main(int argc, char *argv[])
"*Box*vSpace: 1",
NULL
};
+ static const char * const usage =
+ "Usage: xkbwatch [-options ...]\n"
+ "\n"
+ "where options include all standard toolkit options plus:\n"
+ " -help Print usage message and exit\n"
+ " -version Print version and exit\n";
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-version") == 0) {
+ /* Handle args that don't require opening a display */
+ for (int a = 1; a < argc; a++) {
+ const char *argn = argv[a];
+ /* accept single or double dash for -help & -version */
+ if (argn[0] == '-' && argn[1] == '-') {
+ argn++;
+ }
+ if (strcmp(argn, "-help") == 0) {
+ fputs(usage, stdout);
+ exit(EXIT_SUCCESS);
+ }
+ if (strcmp(argn, "-version") == 0) {
printf("xkbwatch (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
- exit(0);
+ exit(EXIT_SUCCESS);
}
}
@@ -94,6 +110,16 @@ main(int argc, char *argv[])
uFatalError("Couldn't create application top level\n");
exit(1);
}
+ if (argc > 1) {
+ fputs("Unrecognized argument(s):", stderr);
+ for (int a = 1; a < argc; a++) {
+ fprintf(stderr, " %s", argv[a]);
+ }
+ fputs("\n\n", stderr);
+ fputs(usage, stderr);
+ exit(EXIT_FAILURE);
+ }
+
inDpy = outDpy = XtDisplay(toplevel);
if (inDpy) {
int i1, mn, mj;