Commit 25938455 authored by Federico G. Schwindt's avatar Federico G. Schwindt

Add -h and use different exit status

parent 590f6e45
...@@ -378,13 +378,13 @@ pass(int sock) ...@@ -378,13 +378,13 @@ pass(int sock)
static void static void
usage(void) usage(int status)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: varnishadm [-n ident] [-t timeout] [-S secretfile] " "Usage: varnishadm [-h] [-n ident] [-t timeout] [-S secretfile] "
"[-T [address]:port] [command [...]]\n"); "[-T [address]:port] [command [...]]\n");
fprintf(stderr, "\t-n is mutually exclusive with -S and -T\n"); fprintf(stderr, "\t-n is mutually exclusive with -S and -T\n");
exit(1); exit(status);
} }
static int static int
...@@ -456,8 +456,11 @@ main(int argc, char * const *argv) ...@@ -456,8 +456,11 @@ main(int argc, char * const *argv)
* The '+' stops that from happening * The '+' stops that from happening
* See #1496 * See #1496
*/ */
while ((opt = getopt(argc, argv, "+n:S:T:t:")) != -1) { while ((opt = getopt(argc, argv, "+hn:S:T:t:")) != -1) {
switch (opt) { switch (opt) {
case 'h':
/* Usage help */
usage(0);
case 'n': case 'n':
n_arg = optarg; n_arg = optarg;
break; break;
...@@ -470,10 +473,10 @@ main(int argc, char * const *argv) ...@@ -470,10 +473,10 @@ main(int argc, char * const *argv)
case 't': case 't':
timeout = VNUM(optarg); timeout = VNUM(optarg);
if (isnan(timeout)) if (isnan(timeout))
usage(); usage(1);
break; break;
default: default:
usage(); usage(1);
} }
} }
...@@ -482,7 +485,7 @@ main(int argc, char * const *argv) ...@@ -482,7 +485,7 @@ main(int argc, char * const *argv)
if (n_arg != NULL) { if (n_arg != NULL) {
if (T_arg != NULL || S_arg != NULL) { if (T_arg != NULL || S_arg != NULL) {
usage(); usage(1);
} }
sock = n_arg_sock(n_arg); sock = n_arg_sock(n_arg);
} else if (T_arg == NULL) { } else if (T_arg == NULL) {
......
...@@ -14,7 +14,7 @@ Control a running Varnish instance ...@@ -14,7 +14,7 @@ Control a running Varnish instance
SYNOPSIS 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 DESCRIPTION
...@@ -35,6 +35,9 @@ replies between the CLI socket and stdin/stdout. ...@@ -35,6 +35,9 @@ replies between the CLI socket and stdin/stdout.
OPTIONS OPTIONS
======= =======
-h
Print program usage and exit.
-n ident -n ident
Connect to the instance of `varnishd` with this name. Connect to the instance of `varnishd` with this name.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment