mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: cli: sort the suggestions by order of relevance
Now the suggested keywords are sorted with the most relevant ones first instead of scanning them all in registration order and only dumping the proposed ones: - "tra" trace <module> [cmd [args...]] : manage live tracing operator : lower the level of the current CLI session to operator user : lower the level of the current CLI session to user show trace [<module>] : show live tracing state - "pool" show pools : report information about the memory pools usage add acl : add acl entry del map : delete map entry user : lower the level of the current CLI session to user del acl : delete acl entry - "sh ta" show stat : report counters for each proxy and server [desc|json|no-maint|typed|up]* show tasks : show running tasks set table [id] : update or create a table entry's data show table [id]: report table usage stats or dump this table's contents trace <module> [cmd [args...]] : manage live tracing - "sh state" show stat : report counters for each proxy and server [desc|json|no-maint|typed|up]* set table [id] : update or create a table entry's data show table [id]: report table usage stats or dump this table's contents show servers state [id]: dump volatile server information (for backend <id>) show sess [id] : report the list of current sessions or dump this session
This commit is contained in:
parent
a9aa628703
commit
ec197e83cd
32
src/cli.c
32
src/cli.c
@ -203,7 +203,26 @@ static char *cli_gen_usage_msg(struct appctx *appctx, char * const *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (matches[0].kw) {
|
||||||
|
/* we have fuzzy matches, let's propose them */
|
||||||
|
for (idx = 0; idx < CLI_MAX_MATCHES; idx++) {
|
||||||
|
kw = matches[idx].kw;
|
||||||
|
if (!kw)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* stop the dump if some words look very unlikely candidates */
|
||||||
|
if (matches[idx].dist > 5*matches[0].dist/2)
|
||||||
|
break;
|
||||||
|
|
||||||
|
chunk_appendf(tmp, " %s\n", kw->usage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
list_for_each_entry(kw_list, &cli_keywords.list, list) {
|
list_for_each_entry(kw_list, &cli_keywords.list, list) {
|
||||||
|
/* no full dump if we've already found nice candidates */
|
||||||
|
if (matches[0].kw)
|
||||||
|
break;
|
||||||
|
|
||||||
for (kw = &kw_list->kw[0]; kw->str_kw[0]; kw++) {
|
for (kw = &kw_list->kw[0]; kw->str_kw[0]; kw++) {
|
||||||
|
|
||||||
/* in a worker or normal process, don't display master-only commands
|
/* in a worker or normal process, don't display master-only commands
|
||||||
@ -228,21 +247,10 @@ static char *cli_gen_usage_msg(struct appctx *appctx, char * const *args)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kw->usage && idx == length) {
|
if (kw->usage && idx == length)
|
||||||
/* if we've filled some fuzzy matches, let's compare them. We'll
|
|
||||||
* just set the idx to their position if they're found and are no
|
|
||||||
* further than twice the distance of the best match, otherwise
|
|
||||||
* idx will be CLI_MAX_MATCHES, indicating "not found".
|
|
||||||
*/
|
|
||||||
for (idx = 0; matches[0].kw && idx < CLI_MAX_MATCHES; idx++)
|
|
||||||
if (kw == matches[idx].kw && matches[idx].dist <= 5*matches[0].dist/2)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (idx < CLI_MAX_MATCHES)
|
|
||||||
chunk_appendf(tmp, " %s\n", kw->usage);
|
chunk_appendf(tmp, " %s\n", kw->usage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* always show the prompt/help/quit commands */
|
/* always show the prompt/help/quit commands */
|
||||||
chunk_strcat(tmp,
|
chunk_strcat(tmp,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user