[rtems commit] shell: Add 'all' topic for help for all commands
Sebastian Huber
sebh at rtems.org
Fri Dec 12 12:18:48 UTC 2014
Module: rtems
Branch: master
Commit: 26e04e2f0201487fac3a1beece62292349b7d183
Changeset: http://git.rtems.org/rtems/commit/?id=26e04e2f0201487fac3a1beece62292349b7d183
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Dec 12 09:42:07 2014 +0100
shell: Add 'all' topic for help for all commands
---
cpukit/libmisc/shell/main_help.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/cpukit/libmisc/shell/main_help.c b/cpukit/libmisc/shell/main_help.c
index 43701d9..e45e7f8 100644
--- a/cpukit/libmisc/shell/main_help.c
+++ b/cpukit/libmisc/shell/main_help.c
@@ -87,7 +87,6 @@ static int rtems_shell_help(
int col,line,lines,arg;
char* lines_env;
rtems_shell_topic_t *topic;
- rtems_shell_cmd_t * shell_cmd = rtems_shell_first_cmd;
lines_env = getenv("SHELL_LINES");
if (lines_env)
@@ -98,7 +97,7 @@ static int rtems_shell_help(
if (argc<2) {
printf("help: The topics are\n");
topic = rtems_shell_first_topic;
- col = 0;
+ col = printf(" all");
while (topic) {
if (!col){
col = printf(" %s",topic->topic);
@@ -117,26 +116,35 @@ static int rtems_shell_help(
}
line = 0;
for (arg = 1;arg<argc;arg++) {
+ const char *cur = argv[arg];
+ rtems_shell_cmd_t *shell_cmd;
+
if (lines && (line > lines)) {
printf("Press any key to continue...");getchar();
printf("\n");
line = 0;
}
- topic = rtems_shell_lookup_topic(argv[arg]);
- if (!topic){
- if ((shell_cmd = rtems_shell_lookup_cmd(argv[arg])) == NULL) {
- printf("help: topic or cmd '%s' not found. Try <help> alone for a list\n",
- argv[arg]);
- line++;
+ topic = rtems_shell_lookup_topic(cur);
+ if (topic == NULL) {
+ if ((shell_cmd = rtems_shell_lookup_cmd(cur)) == NULL) {
+ if (strcmp(cur, "all") != 0) {
+ printf(
+ "help: topic or cmd '%s' not found. Try <help> alone for a list\n",
+ cur
+ );
+ line++;
+ continue;
+ }
} else {
line+= rtems_shell_help_cmd(shell_cmd);
+ continue;
}
- continue;
}
- printf("help: list for the topic '%s'\n",argv[arg]);
+ printf("help: list for the topic '%s'\n",cur);
line++;
+ shell_cmd = rtems_shell_first_cmd;
while (shell_cmd) {
- if (!strcmp(topic->topic,shell_cmd->topic))
+ if (topic == NULL || !strcmp(topic->topic,shell_cmd->topic))
line+= rtems_shell_help_cmd(shell_cmd);
if (lines && (line > lines)) {
printf("Press any key to continue...");
More information about the vc
mailing list