Index: main/frame.c
===================================================================
--- main/frame.c	(revision 82490)
+++ main/frame.c	(working copy)
@@ -611,13 +611,29 @@
 	return ret;
 }
 
-static int show_codecs(int fd, int argc, char *argv[])
+static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
+	int argc, fd;
+	char **argv;
 	int i, found=0;
 	char hex[25];
+
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show codecs [audio|video|image]";
+		e->usage = 
+			"Usage: core show codecs [audio|video|image]\n"
+			"       Displays codec mapping\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+	fd = a->fd;
+	argc = a->argc;
+	argv = a->argv;
 	
 	if ((argc < 3) || (argc > 4))
-		return RESULT_SHOWUSAGE;
+		return CLI_SHOWUSAGE;
 
 	if (!ast_opt_dont_warn)
 		ast_cli(fd, "Disclaimer: this command is for informational purposes only.\n"
@@ -649,25 +665,36 @@
 		}
 	}
 
-	if (! found)
-		return RESULT_SHOWUSAGE;
+	if ( !found )
+		return CLI_SHOWUSAGE;
 	else
-		return RESULT_SUCCESS;
+		return CLI_SUCCESS;
 }
 
-static const char frame_show_codecs_usage[] =
-"Usage: core show codecs [audio|video|image]\n"
-"       Displays codec mapping\n";
-
-static int show_codec_n(int fd, int argc, char *argv[])
+static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	int codec, i, found=0;
+	int codec, i, fd, argc, found=0;
+	char **argv;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show codec";
+		e->usage = 
+			"Usage: core show codec <number>\n"
+			"       Displays codec mapping\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+	fd = a->fd;
+	argc = a->argc;
+	argv = a->argv;
+
 	if (argc != 4)
-		return RESULT_SHOWUSAGE;
+		return CLI_SHOWUSAGE;
 
 	if (sscanf(argv[3],"%d",&codec) != 1)
-		return RESULT_SHOWUSAGE;
+		return CLI_SHOWUSAGE;
 
 	for (i = 0; i < 32; i++)
 		if (codec & (1 << i)) {
@@ -678,13 +705,9 @@
 	if (!found)
 		ast_cli(fd, "Codec %d not found\n", codec);
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
-static char frame_show_codec_n_usage[] =
-"Usage: core show codec <number>\n"
-"       Displays codec mapping\n";
-
 /*! Dump a frame for debugging purposes */
 void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
 {
@@ -867,12 +890,25 @@
 
 
 #ifdef TRACE_FRAMES
-static int show_frame_stats(int fd, int argc, char *argv[])
+static char *show_frame_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_frame *f;
-	int x=1;
-	if (argc != 4)
-		return RESULT_SHOWUSAGE;
+	int fd, x=1;
+
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show frame stats";
+		e->usage = 
+			"Usage: core show frame stats\n"
+			"       Displays debugging statistics from framer\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;	
+	}
+	fd = a->fd;
+
+	if (a->argc != 4)
+		return CLI_SHOWUSAGE;
 	AST_LIST_LOCK(&headerlist);
 	ast_cli(fd, "     Framer Statistics     \n");
 	ast_cli(fd, "---------------------------\n");
@@ -881,40 +917,16 @@
 	AST_LIST_TRAVERSE(&headerlist, f, frame_list)
 		ast_cli(fd, "%d.  Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
 	AST_LIST_UNLOCK(&headerlist);
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
-
-static const char frame_stats_usage[] =
-"Usage: core show frame stats\n"
-"       Displays debugging statistics from framer\n";
 #endif
 
 /* Builtin Asterisk CLI-commands for debugging */
 static struct ast_cli_entry my_clis[] = {
-	{ { "core", "show", "codecs", NULL },
-	show_codecs, "Displays a list of codecs",
-	frame_show_codecs_usage },
-
-	{ { "core", "show", "codecs", "audio", NULL },
-	show_codecs, "Displays a list of audio codecs",
-	frame_show_codecs_usage },
-
-	{ { "core", "show", "codecs", "video", NULL },
-	show_codecs, "Displays a list of video codecs",
-	frame_show_codecs_usage },
-
-	{ { "core", "show", "codecs", "image", NULL },
-	show_codecs, "Displays a list of image codecs",
-	frame_show_codecs_usage },
-
-	{ { "core", "show", "codec", NULL },
-	show_codec_n, "Shows a specific codec",
-	frame_show_codec_n_usage },
-
+	NEW_CLI(show_codecs, "Displays a list of codecs"),
+	NEW_CLI(show_codec_n, "Shows a specific codec"),
 #ifdef TRACE_FRAMES
-	{ { "core", "show", "frame", "stats", NULL },
-	show_frame_stats, "Shows frame statistics",
-	frame_stats_usage },
+	NEW_CLI(show_frame_stats, "Shows frame statistics"),
 #endif
 };
 
Index: main/logger.c
===================================================================
--- main/logger.c	(revision 82490)
+++ main/logger.c	(working copy)
@@ -616,30 +616,68 @@
 	return res;
 }
 
-static int handle_logger_reload(int fd, int argc, char *argv[])
+static char *handle_logger_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
+	int fd;
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "logger reload";
+		e->usage = 
+			"Usage: logger reload\n"
+			"       Reloads the logger subsystem state.  Use after restarting syslogd(8) if you are using syslog logging.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+	fd = a->fd;
 	if (reload_logger(0)) {
 		ast_cli(fd, "Failed to reload the logger\n");
-		return RESULT_FAILURE;
+		return CLI_FAILURE;
 	} else
-		return RESULT_SUCCESS;
+		return CLI_SUCCESS;
 }
 
-static int handle_logger_rotate(int fd, int argc, char *argv[])
+static char *handle_logger_rotate(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
+	int fd;
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "logger rotate";
+		e->usage = 
+			"Usage: logger rotate\n"
+			"       Rotates and Reopens the log files.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;	
+	}
+	fd = a->fd;
 	if (reload_logger(1)) {
 		ast_cli(fd, "Failed to reload the logger and rotate log files\n");
-		return RESULT_FAILURE;
+		return CLI_FAILURE;
 	} else
-		return RESULT_SUCCESS;
+		return CLI_SUCCESS;
 }
 
 /*! \brief CLI command to show logging system configuration */
-static int handle_logger_show_channels(int fd, int argc, char *argv[])
+static char *handle_logger_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 #define FORMATL	"%-35.35s %-8.8s %-9.9s "
+	int fd, argc;
+	char **argv;
 	struct logchannel *chan;
-
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "logger show channels";
+		e->usage = 
+			"Usage: logger show channels\n"
+			"       List configured logger channels.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;	
+	}
+	fd = a->fd;
+	argc = a->argc;
+	argv = a->argv;
 	ast_cli(fd,FORMATL, "Channel", "Type", "Status");
 	ast_cli(fd, "Configuration\n");
 	ast_cli(fd,FORMATL, "-------", "----", "------");
@@ -668,7 +706,7 @@
 	AST_RWLIST_UNLOCK(&logchannels);
 	ast_cli(fd, "\n");
  		
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
 struct verb {
@@ -678,30 +716,10 @@
 
 static AST_RWLIST_HEAD_STATIC(verbosers, verb);
 
-static char logger_reload_help[] =
-"Usage: logger reload\n"
-"       Reloads the logger subsystem state.  Use after restarting syslogd(8) if you are using syslog logging.\n";
-
-static char logger_rotate_help[] =
-"Usage: logger rotate\n"
-"       Rotates and Reopens the log files.\n";
-
-static char logger_show_channels_help[] =
-"Usage: logger show channels\n"
-"       List configured logger channels.\n";
-
 static struct ast_cli_entry cli_logger[] = {
-	{ { "logger", "show", "channels", NULL }, 
-	handle_logger_show_channels, "List configured log channels",
-	logger_show_channels_help },
-
-	{ { "logger", "reload", NULL }, 
-	handle_logger_reload, "Reopens the log files",
-	logger_reload_help },
-
-	{ { "logger", "rotate", NULL }, 
-	handle_logger_rotate, "Rotates and reopens the log files",
-	logger_rotate_help },
+	NEW_CLI(handle_logger_show_channels, "List configured log channels"),
+	NEW_CLI(handle_logger_reload, "Reopens the log files"),
+	NEW_CLI(handle_logger_rotate, "Rotates and reopens the log files")
 };
 
 static int handle_SIGXFSZ(int sig) 
Index: main/pbx.c
===================================================================
--- main/pbx.c	(revision 82490)
+++ main/pbx.c	(working copy)
@@ -1246,16 +1246,33 @@
 	}
 }
 
-static int handle_show_functions(int fd, int argc, char *argv[])
+static char *handle_show_functions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_custom_function *acf;
 	int count_acf = 0;
 	int like = 0;
+	int fd, argc;
+	char **argv;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show functions [like]";
+		e->usage = 
+			"Usage: core show functions [like <text>]\n"
+			"       List builtin functions, optionally only those matching a given string\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	fd = a->fd;
+	argc = a->argc;
+	argv = a->argv;
+
 	if (argc == 5 && (!strcmp(argv[3], "like")) ) {
 		like = 1;
 	} else if (argc != 3) {
-		return RESULT_SHOWUSAGE;
+		return CLI_SHOWUSAGE;
 	}
 
 	ast_cli(fd, "%s Custom Functions:\n--------------------------------------------------------------------------------\n", like ? "Matching" : "Installed");
@@ -1271,10 +1288,10 @@
 
 	ast_cli(fd, "%d %scustom functions installed.\n", count_acf, like ? "matching " : "");
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
-static int handle_show_function(int fd, int argc, char *argv[])
+static char *handle_show_function(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_custom_function *acf;
 	/* Maximum number of characters added by terminal coloring is 22 */
@@ -1282,13 +1299,44 @@
 	char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL;
 	char stxtitle[40], *syntax = NULL;
 	int synopsis_size, description_size, syntax_size;
+	int fd, argc;
+	char **argv;
+	char *ret = NULL;
+	int which = 0;
+	int wordlen;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show function";
+		e->usage = 
+			"Usage: core show function <function>\n"
+			"       Describe a particular dialplan function.\n";
+		return NULL;
+	case CLI_GENERATE:	
+		wordlen = strlen(a->word);
+		/* case-insensitive for convenience in this 'complete' function */
+		AST_RWLIST_RDLOCK(&acf_root);
+		AST_RWLIST_TRAVERSE(&acf_root, acf, acflist) {
+			if (!strncasecmp(a->word, acf->name, wordlen) && ++which > a->n) {
+				ret = ast_strdup(acf->name);
+				break;
+			}
+		}
+		AST_RWLIST_UNLOCK(&acf_root);
+
+		return ret;
+	}
+
+	fd = a->fd;
+	argc = a->argc;
+	argv = a->argv;
+
 	if (argc < 4)
-		return RESULT_SHOWUSAGE;
+		return CLI_SHOWUSAGE;
 
 	if (!(acf = ast_custom_function_find(argv[3]))) {
 		ast_cli(fd, "No function by that name registered.\n");
-		return RESULT_FAILURE;
+		return CLI_FAILURE;
 
 	}
 
@@ -1327,29 +1375,9 @@
 
 	ast_cli(fd,"%s%s%s\n\n%s%s\n\n%s%s\n", infotitle, stxtitle, syntax, syntitle, synopsis, destitle, description);
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
-static char *complete_show_function(const char *line, const char *word, int pos, int state)
-{
-	struct ast_custom_function *acf;
-	char *ret = NULL;
-	int which = 0;
-	int wordlen = strlen(word);
-
-	/* case-insensitive for convenience in this 'complete' function */
-	AST_RWLIST_RDLOCK(&acf_root);
-	AST_RWLIST_TRAVERSE(&acf_root, acf, acflist) {
- 		if (!strncasecmp(word, acf->name, wordlen) && ++which > state) {
- 			ret = ast_strdup(acf->name);
-			break;
-		}
-	}
-	AST_RWLIST_UNLOCK(&acf_root);
-
-	return ret;
-}
-
 struct ast_custom_function *ast_custom_function_find(const char *name)
 {
 	struct ast_custom_function *acf = NULL;
@@ -3008,89 +3036,55 @@
 /*
  * Help for CLI commands ...
  */
-static char show_applications_help[] =
-"Usage: core show applications [{like|describing} <text>]\n"
-"       List applications which are currently available.\n"
-"       If 'like', <text> will be a substring of the app name\n"
-"       If 'describing', <text> will be a substring of the description\n";
 
-static char show_functions_help[] =
-"Usage: core show functions [like <text>]\n"
-"       List builtin functions, optionally only those matching a given string\n";
-
-static char show_switches_help[] =
-"Usage: core show switches\n"
-"       List registered switches\n";
-
-static char show_hints_help[] =
-"Usage: core show hints\n"
-"       List registered hints\n";
-
-static char show_globals_help[] =
-"Usage: core show globals\n"
-"       List current global dialplan variables and their values\n";
-
-static char show_application_help[] =
-"Usage: core show application <application> [<application> [<application> [...]]]\n"
-"       Describes a particular application.\n";
-
-static char show_function_help[] =
-"Usage: core show function <function>\n"
-"       Describe a particular dialplan function.\n";
-
-static char show_dialplan_help[] =
-"Usage: core show dialplan [exten@][context]\n"
-"       Show dialplan\n";
-
-static char set_global_help[] =
-"Usage: core set global <name> <value>\n"
-"       Set global dialplan variable <name> to <value>\n";
-
-
 /*
- * \brief 'show application' CLI command implementation functions ...
+ * \brief 'show application' CLI command implementation function...
  */
-
-/*
- * There is a possibility to show informations about more than one
- * application at one time. You can type 'show application Dial Echo' and
- * you will see informations about these two applications ...
- */
-static char *complete_show_application(const char *line, const char *word, int pos, int state)
+static char *handle_show_application(struct ast_cli_entry *e, int cmd, struct ast_cli_args *ar)
 {
 	struct ast_app *a;
+	int app, no_registered_app = 1;
 	char *ret = NULL;
 	int which = 0;
-	int wordlen = strlen(word);
+	int wordlen;
 
-	/* return the n-th [partial] matching entry */
-	AST_RWLIST_RDLOCK(&apps);
-	AST_RWLIST_TRAVERSE(&apps, a, list) {
-		if (!strncasecmp(word, a->name, wordlen) && ++which > state) {
-			ret = ast_strdup(a->name);
-			break;
+	switch ( cmd ) {
+	case CLI_INIT:	
+		e->command = "core show application";
+		e->usage = 
+			"Usage: core show application <application> [<application> [<application> [...]]]\n"
+			"       Describes a particular application.\n";
+		return NULL;
+	case CLI_GENERATE:
+		/*
+		 * There is a possibility to show informations about more than one
+		 * application at one time. You can type 'show application Dial Echo' and
+		 * you will see informations about these two applications ...
+		 */
+		wordlen = strlen(ar->word);
+		/* return the n-th [partial] matching entry */
+		AST_RWLIST_RDLOCK(&apps);
+		AST_RWLIST_TRAVERSE(&apps, a, list) {
+			if (!strncasecmp(ar->word, a->name, wordlen) && ++which > ar->n) {
+				ret = ast_strdup(a->name);
+				break;
+			}
 		}
+		AST_RWLIST_UNLOCK(&apps);
+
+		return ret;
 	}
-	AST_RWLIST_UNLOCK(&apps);
 
-	return ret;
-}
+	if ( 4 > ar->argc )
+		return CLI_SHOWUSAGE;
 
-static int handle_show_application(int fd, int argc, char *argv[])
-{
-	struct ast_app *a;
-	int app, no_registered_app = 1;
-
-	if (argc < 4)
-		return RESULT_SHOWUSAGE;
-
 	/* ... go through all applications ... */
 	AST_RWLIST_RDLOCK(&apps);
 	AST_RWLIST_TRAVERSE(&apps, a, list) {
 		/* ... compare this application name with all arguments given
 		 * to 'show application' command ... */
-		for (app = 3; app < argc; app++) {
-			if (!strcasecmp(a->name, argv[app])) {
+		for (app = 3; app < ar->argc; app++) {
+			if (!strcasecmp(a->name, ar->argv[app])) {
 				/* Maximum number of characters added by terminal coloring is 22 */
 				char infotitle[64 + AST_MAX_APP + 22], syntitle[40], destitle[40];
 				char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL;
@@ -3122,10 +3116,10 @@
 									a->description ? a->description : "Not available",
 									COLOR_CYAN, 0, description_size);
 
-					ast_cli(fd,"%s%s%s\n\n%s%s\n", infotitle, syntitle, synopsis, destitle, description);
+					ast_cli(ar->fd,"%s%s%s\n\n%s%s\n", infotitle, syntitle, synopsis, destitle, description);
 				} else {
 					/* ... one of our applications, show info ...*/
-					ast_cli(fd,"\n  -= Info about application '%s' =- \n\n"
+					ast_cli(ar->fd,"\n  -= Info about application '%s' =- \n\n"
 						"[Synopsis]\n  %s\n\n"
 						"[Description]\n%s\n",
 						a->name,
@@ -3139,81 +3133,122 @@
 
 	/* we found at least one app? no? */
 	if (no_registered_app) {
-		ast_cli(fd, "Your application(s) is (are) not registered\n");
-		return RESULT_FAILURE;
+		ast_cli(ar->fd, "Your application(s) is (are) not registered\n");
+		return CLI_FAILURE;
 	}
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
 /*! \brief  handle_show_hints: CLI support for listing registered dial plan hints */
-static int handle_show_hints(int fd, int argc, char *argv[])
+static char *handle_show_hints(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_hint *hint;
 	int num = 0;
 	int watchers;
 	struct ast_state_cb *watcher;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show hints";
+		e->usage = 
+			"Usage: core show hints\n"
+			"       List registered hints\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;	
+	}
+
 	AST_RWLIST_RDLOCK(&hints);
 	if (AST_RWLIST_EMPTY(&hints)) {
-		ast_cli(fd, "There are no registered dialplan hints\n");
+		ast_cli(a->fd, "There are no registered dialplan hints\n");
 		AST_RWLIST_UNLOCK(&hints);
-		return RESULT_SUCCESS;
+		return CLI_SUCCESS;
 	}
 	/* ... we have hints ... */
-	ast_cli(fd, "\n    -= Registered Asterisk Dial Plan Hints =-\n");
+	ast_cli(a->fd, "\n    -= Registered Asterisk Dial Plan Hints =-\n");
 	AST_RWLIST_TRAVERSE(&hints, hint, list) {
 		watchers = 0;
 		for (watcher = hint->callbacks; watcher; watcher = watcher->next)
 			watchers++;
-		ast_cli(fd, "   %20s@%-20.20s: %-20.20s  State:%-15.15s Watchers %2d\n",
+		ast_cli(a->fd, "   %20s@%-20.20s: %-20.20s  State:%-15.15s Watchers %2d\n",
 			ast_get_extension_name(hint->exten),
 			ast_get_context_name(ast_get_extension_context(hint->exten)),
 			ast_get_extension_app(hint->exten),
 			ast_extension_state2str(hint->laststate), watchers);
 		num++;
 	}
-	ast_cli(fd, "----------------\n");
-	ast_cli(fd, "- %d hints registered\n", num);
+	ast_cli(a->fd, "----------------\n");
+	ast_cli(a->fd, "- %d hints registered\n", num);
 	AST_RWLIST_UNLOCK(&hints);
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
 /*! \brief  handle_show_switches: CLI support for listing registered dial plan switches */
-static int handle_show_switches(int fd, int argc, char *argv[])
+static char *handle_show_switches(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_switch *sw;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show switches";
+		e->usage = 
+			"Usage: core show switches\n"
+			"       List registered switches\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;	
+	}
+
 	AST_RWLIST_RDLOCK(&switches);
 
 	if (AST_RWLIST_EMPTY(&switches)) {
 		AST_RWLIST_UNLOCK(&switches);
-		ast_cli(fd, "There are no registered alternative switches\n");
+		ast_cli(a->fd, "There are no registered alternative switches\n");
 		return RESULT_SUCCESS;
 	}
 
-	ast_cli(fd, "\n    -= Registered Asterisk Alternative Switches =-\n");
+	ast_cli(a->fd, "\n    -= Registered Asterisk Alternative Switches =-\n");
 	AST_RWLIST_TRAVERSE(&switches, sw, list)
-		ast_cli(fd, "%s: %s\n", sw->name, sw->description);
+		ast_cli(a->fd, "%s: %s\n", sw->name, sw->description);
 
 	AST_RWLIST_UNLOCK(&switches);
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
-static int handle_show_applications(int fd, int argc, char *argv[])
+static char *handle_show_applications(struct ast_cli_entry *e, int cmd, struct ast_cli_args *ar)
 {
 	struct ast_app *a;
 	int like = 0, describing = 0;
 	int total_match = 0; 	/* Number of matches in like clause */
 	int total_apps = 0; 	/* Number of apps registered */
+	static char* choices[] = { "like", "describing", NULL };
+	int fd, argc;
+	char **argv;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show applications [like|describing]";
+		e->usage = 
+			"Usage: core show applications [{like|describing} <text>]\n"
+			"       List applications which are currently available.\n"
+			"       If 'like', <text> will be a substring of the app name\n"
+			"       If 'describing', <text> will be a substring of the description\n";
+		return NULL;
+	case CLI_GENERATE:
+		return ( 3 != ar->pos ) ? NULL : ast_cli_complete(ar->word, choices, ar->n);
+	}
+	fd = ar->fd;
+	argc = ar->argc;
+	argv = ar->argv;
+
 	AST_RWLIST_RDLOCK(&apps);
 
 	if (AST_RWLIST_EMPTY(&apps)) {
 		ast_cli(fd, "There are no registered applications\n");
 		AST_RWLIST_UNLOCK(&apps);
-		return -1;
+		return CLI_SUCCESS;
 	}
 
 	/* core list applications like <keyword> */
@@ -3267,16 +3302,9 @@
 
 	AST_RWLIST_UNLOCK(&apps);
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
-static char *complete_show_applications(const char *line, const char *word, int pos, int state)
-{
-	static char* choices[] = { "like", "describing", NULL };
-
-	return (pos != 3) ? NULL : ast_cli_complete(word, choices, state);
-}
-
 /*
  * 'show dialplan' CLI command implementation functions ...
  */
@@ -3485,17 +3513,33 @@
 	return (dpc->total_exten == old_total_exten) ? -1 : res;
 }
 
-static int handle_show_dialplan(int fd, int argc, char *argv[])
+static char *handle_show_dialplan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	char *exten = NULL, *context = NULL;
 	/* Variables used for different counters */
 	struct dialplan_counters counters;
+	const char *incstack[AST_PBX_MAX_STACK];
+	int fd, argc;
+	char **argv;
 
-	const char *incstack[AST_PBX_MAX_STACK];
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "dialplan show";
+		e->usage = 
+			"Usage: core show dialplan [exten@][context]\n"
+			"       Show dialplan\n";
+		return NULL;
+	case CLI_GENERATE:	
+		return complete_show_dialplan_context(a->line, a->word, a->pos, a->n);
+	}
+
+	fd = a->fd;
+	argc = a->argc;
+	argv = a->argv;
 	memset(&counters, 0, sizeof(counters));
 
 	if (argc != 2 && argc != 3)
-		return RESULT_SHOWUSAGE;
+		return CLI_SHOWUSAGE;
 
 	/* we obtain [exten@]context? if yes, split them ... */
 	if (argc == 3) {
@@ -3517,7 +3561,7 @@
 	/* check for input failure and throw some error messages */
 	if (context && !counters.context_existence) {
 		ast_cli(fd, "There is no existence of '%s' context\n", context);
-		return RESULT_FAILURE;
+		return CLI_FAILURE;
 	}
 
 	if (exten && !counters.extension_existence) {
@@ -3528,7 +3572,7 @@
 			ast_cli(fd,
 				"There is no existence of '%s' extension in all contexts\n",
 				exten);
-		return RESULT_FAILURE;
+		return CLI_FAILURE;
 	}
 
 	ast_cli(fd,"-= %d %s (%d %s) in %d %s. =-\n",
@@ -3537,7 +3581,7 @@
 				counters.total_context, counters.total_context == 1 ? "context" : "contexts");
 
 	/* everything ok */
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
 /*! \brief Send ack once */
@@ -3751,74 +3795,68 @@
 
 
 /*! \brief CLI support for listing global variables in a parseable way */
-static int handle_show_globals(int fd, int argc, char *argv[])
+static char *handle_show_globals(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	int i = 0;
 	struct ast_var_t *newvariable;
 
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core show globals";
+		e->usage = 
+			"Usage: core show globals\n"
+			"       List current global dialplan variables and their values\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
 	ast_rwlock_rdlock(&globalslock);
 	AST_LIST_TRAVERSE (&globals, newvariable, entries) {
 		i++;
-		ast_cli(fd, "   %s=%s\n", ast_var_name(newvariable), ast_var_value(newvariable));
+		ast_cli(a->fd, "   %s=%s\n", ast_var_name(newvariable), ast_var_value(newvariable));
 	}
 	ast_rwlock_unlock(&globalslock);
-	ast_cli(fd, "\n    -- %d variables\n", i);
+	ast_cli(a->fd, "\n    -- %d variables\n", i);
 
-	return RESULT_SUCCESS;
+	return CLI_SUCCESS;
 }
 
-static int handle_set_global(int fd, int argc, char *argv[])
+static char *handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	if (argc != 5)
-		return RESULT_SHOWUSAGE;
+	switch ( cmd ) {
+	case CLI_INIT:
+		e->command = "core set global";
+		e->usage = 
+			"Usage: core set global <name> <value>\n"
+			"       Set global dialplan variable <name> to <value>\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;	
+	}
 
-	pbx_builtin_setvar_helper(NULL, argv[3], argv[4]);
-	ast_cli(fd, "\n    -- Global variable %s set to %s\n", argv[3], argv[4]);
+	if ( 5 != a->argc )
+		return CLI_SHOWUSAGE;
 
-	return RESULT_SUCCESS;
+	pbx_builtin_setvar_helper(NULL, a->argv[3], a->argv[4]);
+	ast_cli(a->fd, "\n    -- Global variable %s set to %s\n", a->argv[3], a->argv[4]);
+
+	return CLI_SUCCESS;
 }
 
-
-
 /*
  * CLI entries for upper commands ...
  */
 static struct ast_cli_entry pbx_cli[] = {
-	{ { "core", "show", "applications", NULL },
-	handle_show_applications, "Shows registered dialplan applications",
-	show_applications_help, complete_show_applications },
-
-	{ { "core", "show", "functions", NULL },
-	handle_show_functions, "Shows registered dialplan functions",
-	show_functions_help },
-
-	{ { "core", "show", "switches", NULL },
-	handle_show_switches, "Show alternative switches",
-	show_switches_help },
-
-	{ { "core", "show", "hints", NULL },
-	handle_show_hints, "Show dialplan hints",
-	show_hints_help },
-
-	{ { "core", "show", "globals", NULL },
-	handle_show_globals, "Show global dialplan variables",
-	show_globals_help },
-
-	{ { "core", "show" , "function", NULL },
-	handle_show_function, "Describe a specific dialplan function",
-	show_function_help, complete_show_function },
-
-	{ { "core", "show", "application", NULL },
-	handle_show_application, "Describe a specific dialplan application",
-	show_application_help, complete_show_application },
-
-	{ { "core", "set", "global", NULL },
-	handle_set_global, "Set global dialplan variable",
-	set_global_help },
-
-	{ { "dialplan", "show", NULL },
-	handle_show_dialplan, "Show dialplan",
-	show_dialplan_help, complete_show_dialplan_context },
+	NEW_CLI(handle_show_applications, "Shows registered dialplan applications"),
+	NEW_CLI(handle_show_functions, "Shows registered dialplan functions"),
+	NEW_CLI(handle_show_switches, "Show alternative switches"),
+	NEW_CLI(handle_show_hints, "Show dialplan hints"),
+	NEW_CLI(handle_show_globals, "Show global dialplan variables"),
+	NEW_CLI(handle_show_function, "Describe a specific dialplan function"),
+	NEW_CLI(handle_show_application, "Describe a specific dialplan application"),
+	NEW_CLI(handle_set_global, "Set global dialplan variable"),
+	NEW_CLI(handle_show_dialplan, "Show dialplan"),
 };
 
 static void unreference_cached_app(struct ast_app *app)
