U_BOOT_CMD(
version, 1, 1, do_version,
- "version - print monitor version\n",
+ "print monitor version",
NULL
);
}
U_BOOT_CMD(
- echo, CFG_MAXARGS, 1, do_echo,
- "echo - echo args to console\n",
+ echo, CONFIG_SYS_MAXARGS, 1, do_echo,
+ "echo args to console",
"[args..]\n"
" - echo args to console; \\c suppresses newline\n"
);
#endif
-#ifdef CFG_HUSH_PARSER
+#ifdef CONFIG_SYS_HUSH_PARSER
int
do_test (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
U_BOOT_CMD(
- test, CFG_MAXARGS, 1, do_test,
- "test - minimal test like /bin/sh\n",
+ test, CONFIG_SYS_MAXARGS, 1, do_test,
+ "minimal test like /bin/sh",
"[args..]\n"
" - test functionality\n"
);
U_BOOT_CMD(
exit, 2, 1, do_exit,
- "exit - exit script\n",
+ "exit script",
" - exit functionality\n"
);
return 1;
if (usage == NULL)
continue;
- puts (usage);
+ printf("%-*s- %s\n", CONFIG_SYS_HELP_CMD_WIDTH,
+ cmd_array[i]->name, usage);
}
return 0;
}
*/
for (i = 1; i < argc; ++i) {
if ((cmdtp = find_cmd (argv[i])) != NULL) {
-#ifdef CFG_LONGHELP
+#ifdef CONFIG_SYS_LONGHELP
/* found - print (long) help info */
puts (cmdtp->name);
putc (' ');
putc ('\n');
#else /* no long help available */
if (cmdtp->usage)
- puts (cmdtp->usage);
-#endif /* CFG_LONGHELP */
+ printf ("%s - %s\n", cmdtp->name, cmdtp->usage);
+#endif /* CONFIG_SYS_LONGHELP */
} else {
printf ("Unknown command '%s' - try 'help'"
" without arguments for list of all"
U_BOOT_CMD(
- help, CFG_MAXARGS, 1, do_help,
- "help - print online help\n",
+ help, CONFIG_SYS_MAXARGS, 1, do_help,
+ "print online help",
"[command ...]\n"
" - show help information (for 'command')\n"
"'help' prints online help for the monitor commands.\n\n"
);
/* This do not ust the U_BOOT_CMD macro as ? can't be used in symbol names */
-#ifdef CFG_LONGHELP
+#ifdef CONFIG_SYS_LONGHELP
cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = {
- "?", CFG_MAXARGS, 1, do_help,
- "? - alias for 'help'\n",
+ "?", CONFIG_SYS_MAXARGS, 1, do_help,
+ "alias for 'help'",
NULL
};
#else
cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = {
- "?", CFG_MAXARGS, 1, do_help,
- "? - alias for 'help'\n"
+ "?", CONFIG_SYS_MAXARGS, 1, do_help,
+ "alias for 'help'"
};
-#endif /* CFG_LONGHELP */
+#endif /* CONFIG_SYS_LONGHELP */
/***************************************************************************
* find command table entry for a command
*/
-cmd_tbl_t *find_cmd (const char *cmd)
+cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len)
{
cmd_tbl_t *cmdtp;
- cmd_tbl_t *cmdtp_temp = &__u_boot_cmd_start; /*Init value */
+ cmd_tbl_t *cmdtp_temp = table; /*Init value */
const char *p;
int len;
int n_found = 0;
*/
len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd);
- for (cmdtp = &__u_boot_cmd_start;
- cmdtp != &__u_boot_cmd_end;
+ for (cmdtp = table;
+ cmdtp != table + table_len;
cmdtp++) {
if (strncmp (cmd, cmdtp->name, len) == 0) {
if (len == strlen (cmdtp->name))
return NULL; /* not found or ambiguous command */
}
+cmd_tbl_t *find_cmd (const char *cmd)
+{
+ int len = &__u_boot_cmd_end - &__u_boot_cmd_start;
+ return find_cmd_tbl(cmd, &__u_boot_cmd_start, len);
+}
+
+void cmd_usage(cmd_tbl_t *cmdtp)
+{
+ printf("Usage:\n%s - %s\n\n", cmdtp->name, cmdtp->usage);
+}
+
#ifdef CONFIG_AUTO_COMPLETE
int var_complete(int argc, char *argv[], char last_char, int maxv, char *cmdv[])
return len;
}
-static char tmp_buf[CFG_CBSIZE]; /* copy of console I/O buffer */
+static char tmp_buf[CONFIG_SYS_CBSIZE]; /* copy of console I/O buffer */
int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp)
{
int n = *np, col = *colp;
- char *argv[CFG_MAXARGS + 1]; /* NULL terminated */
+ char *argv[CONFIG_SYS_MAXARGS + 1]; /* NULL terminated */
char *cmdv[20];
char *s, *t;
const char *sep;
int cnt;
char last_char;
- if (strcmp(prompt, CFG_PROMPT) != 0)
+ if (strcmp(prompt, CONFIG_SYS_PROMPT) != 0)
return 0; /* not in normal console */
cnt = strlen(buf);
if (s != NULL) {
k = len + seplen;
/* make sure it fits */
- if (n + k >= CFG_CBSIZE - 2) {
+ if (n + k >= CONFIG_SYS_CBSIZE - 2) {
putc('\a');
return 1;
}