summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-11 17:04:31 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-11 17:06:07 -0800
commit1a829930f7b5b00e5fa128c6dd0dd1a7c4065213 (patch)
treec6949839c354104b53023d0af60b5080a964099c
parent1b141ab13d101fa7a2c4ab3a220307643d419655 (diff)
Add -help option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xrefresh.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/xrefresh.c b/xrefresh.c
index 768f8eb..6352747 100644
--- a/xrefresh.c
+++ b/xrefresh.c
@@ -70,9 +70,11 @@ static Window win;
static char *ProgramName;
static void _X_NORETURN _X_COLD
-Syntax(void)
+Syntax(int exitval)
{
- fprintf (stderr, "usage: %s [-options] [geometry] [display]\n\n%s",
+ FILE *out = (exitval == EXIT_SUCCESS) ? stdout : stderr;
+
+ fprintf (out, "usage: %s [-options] [geometry] [display]\n\n%s",
ProgramName,
"where the available options are:\n"
" -display host:dpy or -d\n"
@@ -85,22 +87,22 @@ Syntax(void)
" -delay ms time to hold refresh\n"
" -version print program version\n"
);
- fprintf(stderr, "\nThe default is: %s -none -delay 0\n\n", ProgramName);
- exit (1);
+ fprintf(out, "\nThe default is: %s -none -delay 0\n\n", ProgramName);
+ exit (exitval);
}
static void _X_NORETURN _X_COLD
missing_arg(const char *arg)
{
fprintf (stderr, "%s: %s requires an argument\n\n", ProgramName, arg);
- Syntax ();
+ Syntax (EXIT_FAILURE);
}
static void _X_NORETURN _X_COLD
unknown_arg(const char *arg)
{
fprintf (stderr, "%s: unrecognized argument %s\n\n", ProgramName, arg);
- Syntax ();
+ Syntax (EXIT_FAILURE);
}
/*
@@ -238,7 +240,10 @@ main(int argc, char *argv[])
}
else if (isabbreviation ("-version", arg, 1)) {
puts(PACKAGE_STRING);
- exit(0);
+ exit(EXIT_SUCCESS);
+ }
+ else if (isabbreviation ("-help", arg, 1)) {
+ Syntax(EXIT_SUCCESS);
} else
unknown_arg (arg);
} else if (arg[0] == '=') /* obsolete */