From 69c6f1f7eab96ea47328ece9d71292a71af6ce9c Mon Sep 17 00:00:00 2001 From: oharboe Date: Fri, 11 Jul 2008 15:07:58 +0000 Subject: work in progress to improve help git-svn-id: svn://svn.berlios.de/openocd/trunk@792 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/helper/Makefile.am | 2 +- src/helper/command.c | 24 ++++++++++++++++++++---- src/helper/configuration.c | 5 ++++- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src/helper') diff --git a/src/helper/Makefile.am b/src/helper/Makefile.am index 1f3d76b6..8a2d472e 100644 --- a/src/helper/Makefile.am +++ b/src/helper/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES = $(all_includes) +INCLUDES = -I$(top_srcdir)/src $(all_includes) METASOURCES = AUTO AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" -DPKGLIBDIR=\"$(pkglibdir)\" @CPPFLAGS@ noinst_LIBRARIES = libhelper.a diff --git a/src/helper/command.c b/src/helper/command.c index d2abb0c2..e536cca5 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -38,6 +38,8 @@ #include #include +#include + int fast_and_dangerous = 0; void command_print_help_line(command_context_t* context, struct command_s *command, int indent); @@ -65,10 +67,9 @@ command_t* register_command(command_context_t *context, command_t *parent, char c->children = NULL; c->handler = handler; c->mode = mode; - if (help) - c->help = strdup(help); - else - c->help = NULL; + if (!help) + help=""; + c->help = strdup(help); c->next = NULL; /* place command in tree */ @@ -100,7 +101,22 @@ command_t* register_command(command_context_t *context, command_t *parent, char context->commands = c; } } + /* accumulate help text in Tcl helptext list. */ + Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); + Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0); + + Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0); + + /* maximum of two levels :-) */ + if (c->parent!=NULL) + { + Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, c->parent->name, -1)); + } + Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, c->name, -1)); + Jim_ListAppendElement(interp, cmd_entry, cmd_list); + Jim_ListAppendElement(interp, cmd_entry, Jim_NewStringObj(interp, c->help, -1)); + Jim_ListAppendElement(interp, helptext, cmd_entry); return c; } diff --git a/src/helper/configuration.c b/src/helper/configuration.c index ff8b0272..e9a13ead 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -106,6 +106,7 @@ FILE *open_file_from_path (char *file, char *mode) int parse_config_file(struct command_context_s *cmd_ctx) { + int retval; char **cfg; if (!config_file_names) @@ -115,7 +116,9 @@ int parse_config_file(struct command_context_s *cmd_ctx) while (*cfg) { - command_run_line(cmd_ctx, *cfg); + retval=command_run_line(cmd_ctx, *cfg); + if (retval!=ERROR_OK) + return retval; cfg++; } -- cgit v1.2.3