[4.1] e01a49e Add -h and use different exit status
Lasse Karstensen
lkarsten at varnish-software.com
Tue Jun 14 15:25:12 CEST 2016
commit e01a49e157784c06d532be47862c652440c78b6a
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Sat Jun 4 16:39:24 2016 +0100
Add -h and use different exit status
diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index e426f0b..e90df71 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -378,13 +378,13 @@ pass(int sock)
static void
-usage(void)
+usage(int status)
{
fprintf(stderr,
- "Usage: varnishadm [-n ident] [-t timeout] [-S secretfile] "
+ "Usage: varnishadm [-h] [-n ident] [-t timeout] [-S secretfile] "
"[-T [address]:port] [command [...]]\n");
fprintf(stderr, "\t-n is mutually exclusive with -S and -T\n");
- exit(1);
+ exit(status);
}
static int
@@ -456,8 +456,11 @@ main(int argc, char * const *argv)
* The '+' stops that from happening
* See #1496
*/
- while ((opt = getopt(argc, argv, "+n:S:T:t:")) != -1) {
+ while ((opt = getopt(argc, argv, "+hn:S:T:t:")) != -1) {
switch (opt) {
+ case 'h':
+ /* Usage help */
+ usage(0);
case 'n':
n_arg = optarg;
break;
@@ -470,10 +473,10 @@ main(int argc, char * const *argv)
case 't':
timeout = VNUM(optarg);
if (isnan(timeout))
- usage();
+ usage(1);
break;
default:
- usage();
+ usage(1);
}
}
@@ -482,7 +485,7 @@ main(int argc, char * const *argv)
if (n_arg != NULL) {
if (T_arg != NULL || S_arg != NULL) {
- usage();
+ usage(1);
}
sock = n_arg_sock(n_arg);
} else if (T_arg == NULL) {
diff --git a/doc/sphinx/reference/varnishadm.rst b/doc/sphinx/reference/varnishadm.rst
index 395a72a..e503671 100644
--- a/doc/sphinx/reference/varnishadm.rst
+++ b/doc/sphinx/reference/varnishadm.rst
@@ -14,7 +14,7 @@ Control a running Varnish instance
SYNOPSIS
========
-varnishadm [-n ident] [-t timeout] [-S secretfile] [-T [address]:port] [command [...]]
+varnishadm [-h] [-n ident] [-t timeout] [-S secretfile] [-T [address]:port] [command [...]]
DESCRIPTION
@@ -35,6 +35,9 @@ replies between the CLI socket and stdin/stdout.
OPTIONS
=======
+-h
+ Print program usage and exit.
+
-n ident
Connect to the instance of `varnishd` with this name.
More information about the varnish-commit
mailing list