From d8e95b8b949970dbeeeeba73b1bc71d7f662e5cc Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 5 Feb 2023 11:13:41 -0800 Subject: Add -help option Signed-off-by: Alan Coopersmith --- xcalc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'xcalc.c') diff --git a/xcalc.c b/xcalc.c index 34fef53..381edff 100644 --- a/xcalc.c +++ b/xcalc.c @@ -120,10 +120,13 @@ main(int argc, char **argv) /* 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 -version */ + /* accept single or double dash for -help & -version */ if (argn[0] == '-' && argn[1] == '-') { argn++; } + if (strcmp(argn, "-help") == 0) { + Syntax(1, argv); + } if (strcmp(argn, "-version") == 0) { puts(PACKAGE_STRING); exit(0); @@ -325,17 +328,21 @@ void Quit(void) */ static void Syntax(int argc, char **argv) { - fprintf(stderr, "%s: unknown options:", argv[0]); - for (int i = 1; i 1) { + fprintf(stderr, "%s: unknown options:", argv[0]); + for (int i = 1; i 1) ? 1 : 0); } /* -- cgit v1.2.3