summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2005-12-05 00:39:15 +0000
committerRussell Bryant <russell@russellbryant.com>2005-12-05 00:39:15 +0000
commitb5dfd1174e21aa74ac9f41a58b700ed0320a5863 (patch)
tree5f7cf4518cd53afeb4a11392dbf8a712d56e7a65
parentf75bd5a29ee3da4bf2dece5ddf6ef3fa5dee8a7a (diff)
add support for 'show functions like <text>' (issue #5923)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--pbx.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/pbx.c b/pbx.c
index f437b27a7..0c0cb668a 100644
--- a/pbx.c
+++ b/pbx.c
@@ -1163,13 +1163,36 @@ static int handle_show_functions(int fd, int argc, char *argv[])
{
struct ast_custom_function *acf;
int count_acf = 0;
+ int print_acf = 0;
+ int like = 0;
- ast_cli(fd, "Installed Custom Functions:\n--------------------------------------------------------------------------------\n");
+ if (argc == 4 && (!strcmp(argv[2], "like")) ) {
+ like = 1;
+ } else if (argc != 2) {
+ return RESULT_SHOWUSAGE;
+ }
+
+ ast_cli(fd, "%s Custom Functions:\n--------------------------------------------------------------------------------\n", like ? "Matching" : "Installed");
+
for (acf = acf_root ; acf; acf = acf->next) {
- ast_cli(fd, "%-20.20s %-35.35s %s\n", acf->name, acf->syntax, acf->synopsis);
- count_acf++;
+ print_acf = 0;
+ if (like) {
+ if (strstr(acf->name, argv[3])) {
+ print_acf = 1;
+ count_acf++;
+ }
+ } else {
+ print_acf = 1;
+ count_acf++;
+ }
+
+ if (print_acf) {
+ ast_cli(fd, "%-20.20s %-35.35s %s\n", acf->name, acf->syntax, acf->synopsis);
+ }
}
- ast_cli(fd, "%d custom functions installed.\n", count_acf);
+
+ ast_cli(fd, "%d %scustom functions installed.\n", count_acf, like ? "matching " : "");
+
return 0;
}
@@ -2966,8 +2989,8 @@ static char show_application_help[] =
" Describes a particular application.\n";
static char show_functions_help[] =
-"Usage: show functions\n"
-" List builtin functions accessable as $(function args)\n";
+"Usage: show functions [like <text>]\n"
+" List builtin functions, optionally only those matching a given string\n";
static char show_function_help[] =
"Usage: show function <function>\n"