Skip to content

Commit

Permalink
vcl.show no param defaults to active vcl
Browse files Browse the repository at this point in the history
  • Loading branch information
Quoll-io authored and bsdphk committed Dec 6, 2021
1 parent b93a741 commit c5676a8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
33 changes: 19 additions & 14 deletions bin/varnishd/cache/cache_vcl.c
Expand Up @@ -946,28 +946,33 @@ vcl_cli_show(struct cli *cli, const char * const *av, void *priv)
{
struct vcl *vcl;
int verbose = 0;
int i;
int i = 2;

ASSERT_CLI();
ASSERT_VCL_ACTIVE();
AZ(priv);
if (!strcmp(av[2], "-v") && av[3] == NULL) {
VCLI_Out(cli, "Too few parameters");
VCLI_SetResult(cli, CLIS_TOOFEW);
return;
} else if (strcmp(av[2], "-v") && av[3] != NULL) {
VCLI_Out(cli, "Unknown options '%s'", av[2]);

if (av[i] != NULL && !strcmp(av[i], "-v")) {
verbose = 1;
i++;
}

if (av[i] == NULL) {
vcl = vcl_active;
AN(vcl);
} else {
vcl = vcl_find(av[i]);
i++;
}

if (av[i] != NULL) {
VCLI_Out(cli, "Too many parameters: '%s'", av[i]);
VCLI_SetResult(cli, CLIS_PARAM);
return;
} else if (av[3] != NULL) {
verbose = 1;
vcl = vcl_find(av[3]);
} else
vcl = vcl_find(av[2]);
}

if (vcl == NULL) {
VCLI_Out(cli, "No VCL named '%s'",
av[3] == NULL ? av[2] : av[3]);
VCLI_Out(cli, "No VCL named '%s'", av[i - 1]);
VCLI_SetResult(cli, CLIS_PARAM);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion bin/varnishtest/tests/c00015.vtc
Expand Up @@ -53,7 +53,8 @@ varnish v1 -cli "vcl.show vcl2"
varnish v1 -cli "vcl.show -v vcl2"
varnish v1 -cli "vcl.discard vcl2"
varnish v1 -cli "vcl.list"
varnish v1 -clierr 104 "vcl.show -v"
varnish v1 -cli "vcl.show"
varnish v1 -cli "vcl.show -v"
varnish v1 -clierr 106 "vcl.show -x nowhere"
varnish v1 -clierr 106 "vcl.show nothere"
varnish v1 -clierr 106 "vcl.use nothere"
Expand Down
4 changes: 2 additions & 2 deletions include/tbl/cli_cmds.h
Expand Up @@ -146,10 +146,10 @@ CLI_CMD(VCL_DEPS,

CLI_CMD(VCL_SHOW,
"vcl.show",
"vcl.show [-v] <configname>",
"vcl.show [-v] [<configname>]",
"Display the source code for the specified configuration.",
"",
1, 2
0, 2
)

CLI_CMD(VCL_USE,
Expand Down

0 comments on commit c5676a8

Please sign in to comment.