From 849b0d42f4cc0e54c56778626effe1e9f1ef238e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 11 Feb 2023 17:16:16 -0800 Subject: Add -help option Signed-off-by: Alan Coopersmith --- xset.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xset.c b/xset.c index 9c0cf26..36d4b7a 100644 --- a/xset.c +++ b/xset.c @@ -168,11 +168,21 @@ main(int argc, char *argv[]) if (++i >= argc) usage("missing argument to -display"); disp = argv[i]; - } else if (strcmp(arg, "-version") == 0) { - puts(PACKAGE_STRING); - exit(EXIT_SUCCESS); } else { - hasargs = True; + /* accept single or double dash for -help & -version */ + if (arg[0] == '-' && arg[1] == '-') { + arg++; + } + + if (strcmp(arg, "-help") == 0) { + usage(NULL); + } + else if (strcmp(arg, "-version") == 0) { + puts(PACKAGE_STRING); + exit(EXIT_SUCCESS); + } + else + hasargs = True; } } if (!hasargs) { -- cgit v1.2.3