MINOR: cli: add an 'echo' command
Add an echo command to write text over the CLI output.
This commit is contained in:
parent
944a224358
commit
dc1c0a169c
|
@ -2131,6 +2131,15 @@ dump stats-file
|
||||||
Generate a stats-file which can be used to preload haproxy counters values on
|
Generate a stats-file which can be used to preload haproxy counters values on
|
||||||
startup. See "Stats-file" section for more detail.
|
startup. See "Stats-file" section for more detail.
|
||||||
|
|
||||||
|
echo <text>
|
||||||
|
Print some text with the CLI. Can be useful to wrote commentaries between
|
||||||
|
commands when dumping the result of multiple commands.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
echo "expert-mode on; echo FDs from fdtab; show fd; echo wild FDs; debug dev fd" | socat /var/run/haproxy.sock -
|
||||||
|
|
||||||
|
|
||||||
enable agent <backend>/<server>
|
enable agent <backend>/<server>
|
||||||
Resume auxiliary agent check that was temporarily stopped.
|
Resume auxiliary agent check that was temporarily stopped.
|
||||||
|
|
||||||
|
|
22
src/cli.c
22
src/cli.c
|
@ -2467,6 +2467,27 @@ static int cli_parse_simple(char **args, char *payload, struct appctx *appctx, v
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cli_parse_echo(char **args, char *payload, struct appctx *appctx, void *private)
|
||||||
|
{
|
||||||
|
int i = 1; /* starts after 'echo' */
|
||||||
|
|
||||||
|
chunk_reset(&trash);
|
||||||
|
|
||||||
|
while (*args[i]) {
|
||||||
|
/* add a space if there was a word before */
|
||||||
|
if (i == 1)
|
||||||
|
chunk_printf(&trash, "%s", args[i]);
|
||||||
|
else
|
||||||
|
chunk_appendf(&trash, " %s", args[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
chunk_appendf(&trash, "\n");
|
||||||
|
|
||||||
|
cli_msg(appctx, LOG_INFO, trash.area);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int _send_status(char **args, char *payload, struct appctx *appctx, void *private)
|
static int _send_status(char **args, char *payload, struct appctx *appctx, void *private)
|
||||||
{
|
{
|
||||||
struct listener *mproxy_li;
|
struct listener *mproxy_li;
|
||||||
|
@ -3631,6 +3652,7 @@ static struct applet mcli_applet = {
|
||||||
/* register cli keywords */
|
/* register cli keywords */
|
||||||
static struct cli_kw_list cli_kws = {{ },{
|
static struct cli_kw_list cli_kws = {{ },{
|
||||||
{ { "help", NULL }, NULL, cli_parse_simple, NULL, NULL, NULL, ACCESS_MASTER },
|
{ { "help", NULL }, NULL, cli_parse_simple, NULL, NULL, NULL, ACCESS_MASTER },
|
||||||
|
{ { "echo", NULL }, "echo <text> : print text to the output", cli_parse_echo, NULL, NULL, NULL, ACCESS_MASTER },
|
||||||
{ { "prompt", NULL }, NULL, cli_parse_simple, NULL, NULL, NULL, ACCESS_MASTER },
|
{ { "prompt", NULL }, NULL, cli_parse_simple, NULL, NULL, NULL, ACCESS_MASTER },
|
||||||
{ { "quit", NULL }, NULL, cli_parse_simple, NULL, NULL, NULL, ACCESS_MASTER },
|
{ { "quit", NULL }, NULL, cli_parse_simple, NULL, NULL, NULL, ACCESS_MASTER },
|
||||||
{ { "_getsocks", NULL }, NULL, _getsocks, NULL },
|
{ { "_getsocks", NULL }, NULL, _getsocks, NULL },
|
||||||
|
|
Loading…
Reference in New Issue