summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-07-11 15:07:58 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-07-11 15:07:58 +0000
commit69c6f1f7eab96ea47328ece9d71292a71af6ce9c (patch)
tree6541cec5290ddb00e0754e77a7d0f90e6b962f42 /src/helper
parentc5b718f5e85c7a884f7610fea46ceea2c3fbd4a7 (diff)
downloadopenocd+libswd-69c6f1f7eab96ea47328ece9d71292a71af6ce9c.tar.gz
openocd+libswd-69c6f1f7eab96ea47328ece9d71292a71af6ce9c.tar.bz2
openocd+libswd-69c6f1f7eab96ea47328ece9d71292a71af6ce9c.tar.xz
openocd+libswd-69c6f1f7eab96ea47328ece9d71292a71af6ce9c.zip
work in progress to improve help
git-svn-id: svn://svn.berlios.de/openocd/trunk@792 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/Makefile.am2
-rw-r--r--src/helper/command.c24
-rw-r--r--src/helper/configuration.c5
3 files changed, 25 insertions, 6 deletions
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 <stdio.h>
#include <unistd.h>
+#include <openocd_tcl.h>
+
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++;
}