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]".
diff --git a/include/haproxy/cli.h b/include/haproxy/cli.h
index 6d66157..f202a4f 100644
--- a/include/haproxy/cli.h
+++ b/include/haproxy/cli.h
@@ -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);
diff --git a/src/cli.c b/src/cli.c
index 6f617b2..9f4b8df 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -368,6 +368,30 @@
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).
diff --git a/src/haproxy.c b/src/haproxy.c
index a2b7d91..16fafc3 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1826,6 +1826,7 @@
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 @@
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);