mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-28 23:52:06 +00:00
MINOR: cli: add a new keyword dump function
New function cli_list_keywords() scans the list of registered CLI keywords and dumps them on stdout. It's now called from dump_registered_keywords() for the class "cli". Some keywords are valid for the master, they'll be suffixed with "[MASTER]". Others are valid for the worker, they'll have "[WORKER]". Those accessible only in expert mode will show "[EXPERT]" and the experimental ones will show "[EXPERIM]".
This commit is contained in:
parent
5fcc100d91
commit
06d0e2e034
@ -33,6 +33,7 @@
|
||||
|
||||
void cli_register_kw(struct cli_kw_list *kw_list);
|
||||
struct cli_kw* cli_find_kw_exact(char **args);
|
||||
void cli_list_keywords(void);
|
||||
|
||||
int cli_has_level(struct appctx *appctx, int level);
|
||||
|
||||
|
24
src/cli.c
24
src/cli.c
@ -368,6 +368,30 @@ void cli_register_kw(struct cli_kw_list *kw_list)
|
||||
LIST_APPEND(&cli_keywords.list, &kw_list->list);
|
||||
}
|
||||
|
||||
/* list all known keywords on stdout, one per line */
|
||||
void cli_list_keywords(void)
|
||||
{
|
||||
struct cli_kw_list *kw_list;
|
||||
struct cli_kw *kw;
|
||||
int idx;
|
||||
|
||||
list_for_each_entry(kw_list, &cli_keywords.list, list) {
|
||||
for (kw = &kw_list->kw[0]; kw->str_kw[0]; kw++) {
|
||||
for (idx = 0; kw->str_kw[idx]; idx++) {
|
||||
printf("%s ", kw->str_kw[idx]);
|
||||
}
|
||||
if (kw->level & (ACCESS_MASTER_ONLY|ACCESS_MASTER))
|
||||
printf("[MASTER] ");
|
||||
if (!(kw->level & ACCESS_MASTER_ONLY))
|
||||
printf("[WORKER] ");
|
||||
if (kw->level & ACCESS_EXPERT)
|
||||
printf("[EXPERT] ");
|
||||
if (kw->level & ACCESS_EXPERIMENTAL)
|
||||
printf("[EXPERIM] ");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* allocate a new stats frontend named <name>, and return it
|
||||
* (or NULL in case of lack of memory).
|
||||
|
@ -1826,6 +1826,7 @@ static void dump_registered_keywords(void)
|
||||
printf("# List of supported keyword classes:\n");
|
||||
printf("all: list all keywords\n");
|
||||
printf("cfg: configuration keywords\n");
|
||||
printf("cli: CLI keywords\n");
|
||||
printf("flt: filter names\n");
|
||||
printf("svc: service names\n");
|
||||
continue;
|
||||
@ -1839,6 +1840,11 @@ static void dump_registered_keywords(void)
|
||||
cfg_dump_registered_keywords();
|
||||
}
|
||||
|
||||
if (all || strcmp(kwd_dump, "cli") == 0) {
|
||||
printf("# List of registered CLI keywords:\n");
|
||||
cli_list_keywords();
|
||||
}
|
||||
|
||||
if (all || strcmp(kwd_dump, "flt") == 0) {
|
||||
printf("# List of registered filter names:\n");
|
||||
flt_dump_kws(NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user