Commit e7ad1e46 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give `varnishadm` a `-p` to disable libreadline and get VCLI compliance.

parent e98e8e64
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
static const double timeout = 5; // XXX should be settable by arg ? static const double timeout = 5; // XXX should be settable by arg ?
static int p_arg = 0;
static void static void
cli_write(int sock, const char *s) cli_write(int sock, const char *s)
...@@ -254,7 +255,10 @@ pass_answer(int fd) ...@@ -254,7 +255,10 @@ pass_answer(int fd)
RL_EXIT(1); RL_EXIT(1);
} }
printf("%u\n", status); if (p_arg)
printf("%-3u %-8zu\n", status, strlen(answer));
else
printf("%u\n", status);
if (answer) { if (answer) {
printf("%s\n", answer); printf("%s\n", answer);
free(answer); free(answer);
...@@ -441,7 +445,7 @@ main(int argc, char * const *argv) ...@@ -441,7 +445,7 @@ 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, "+hn:S:T:t:")) != -1) { while ((opt = getopt(argc, argv, "+hn:pS:T:t:")) != -1) {
switch (opt) { switch (opt) {
case 'h': case 'h':
/* Usage help */ /* Usage help */
...@@ -449,6 +453,9 @@ main(int argc, char * const *argv) ...@@ -449,6 +453,9 @@ main(int argc, char * const *argv)
case 'n': case 'n':
n_arg = optarg; n_arg = optarg;
break; break;
case 'p':
p_arg = 1;
break;
case 'S': case 'S':
S_arg = optarg; S_arg = optarg;
break; break;
...@@ -485,7 +492,7 @@ main(int argc, char * const *argv) ...@@ -485,7 +492,7 @@ main(int argc, char * const *argv)
NEEDLESS(exit(0)); NEEDLESS(exit(0));
} }
if (isatty(0)) if (isatty(0) && !p_arg)
interactive(sock); interactive(sock);
else else
pass(sock); pass(sock);
......
...@@ -14,15 +14,17 @@ client c1 { ...@@ -14,15 +14,17 @@ client c1 {
varnish v1 -vsl_catchup varnish v1 -vsl_catchup
process p1 -log {cat | varnishadm -n ${v1_name}} -start process p1 -log {cat | varnishadm -p -n ${v1_name}} -start
process p1 -write "ping\r" process p1 -write "ping\r"
process p1 -expect-text 0 1 "200 19"
process p1 -expect-text 0 1 "PONG" process p1 -expect-text 0 1 "PONG"
process p1 -write "vcl.list\r" process p1 -write "vcl.list\r"
process p1 -expect-text 0 0 "auto warm" process p1 -expect-text 0 0 "auto warm"
process p1 -write "vcl.show vcl1\r" process p1 -write "vcl.show vcl1\r"
......
...@@ -38,6 +38,11 @@ OPTIONS ...@@ -38,6 +38,11 @@ OPTIONS
-h -h
Print program usage and exit. Print program usage and exit.
-p
Force `pass` mode and make the output follow the VCLI protocol.
This disables command-history/command-completion and makes it
easier for programs to parse the response(s).
-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