2024-11-06 22:03:59 -08:00
|
|
|
/*
|
2024-11-06 22:19:03 -08:00
|
|
|
* help.h
|
2024-11-06 22:03:59 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef USER_SHELL_COMMANDS_HELP_H_
|
|
|
|
#define USER_SHELL_COMMANDS_HELP_H_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cons_help_real(int argc, char **argv, command_table_t *p)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
// print help list
|
|
|
|
if ((shell_flags & 0x02) == 0) {
|
|
|
|
CONS_PRINT("Tip: You only need to use the first two characters ");
|
|
|
|
CONS_PRINT("of a command.\r\n\r\n");
|
|
|
|
shell_flags |= 0x02;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (p->cmd != 0) {
|
|
|
|
if (strlen(p->desc)) {
|
|
|
|
strcpy( console_line, "* ");
|
|
|
|
strncat(console_line, p->cmd, 12);
|
|
|
|
for (i = strlen(console_line); i <= 12; i++) {
|
|
|
|
console_line[i] = 0x20;
|
|
|
|
}
|
|
|
|
console_line[i] = 0x00;
|
|
|
|
strncat(console_line, p->desc, 77);
|
|
|
|
strncat(console_line, "\r\n", 79);
|
|
|
|
console_line[63] = 0;
|
|
|
|
CONS_PRINT(console_line);
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (p->cmd != 0) {
|
|
|
|
// calling the callback with argc/argv set to 0 should instruct it to print help/usage
|
|
|
|
if (strcmp(argv[1], p->cmd) == 0) {
|
|
|
|
p->go(0, (char **)0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// looks like the command wasn't found
|
2024-11-06 22:19:03 -08:00
|
|
|
strcpy( console_line, "* no help found for '");
|
2024-11-06 22:03:59 -08:00
|
|
|
strncat(console_line, argv[1], 60);
|
|
|
|
strncat(console_line, "'\r\n", 62);
|
|
|
|
CONS_PRINT(console_line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cons_help(int argc, char **argv)
|
|
|
|
{
|
|
|
|
cons_help_real(argc, argv, (command_table_t *)console_cmdlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* USER_SHELL_COMMANDS_HELP_H_ */
|