summaryrefslogtreecommitdiff
path: root/src/helper/command.c
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/command.c
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/command.c')
-rw-r--r--src/helper/command.c24
1 files changed, 20 insertions, 4 deletions
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;
}