Fixed up help messages.
This commit is contained in:
parent
ee4deeb3fb
commit
c9697ab25c
42
main.c
42
main.c
|
@ -624,7 +624,7 @@ static const struct command all_commands[] = {
|
||||||
" an argument, displays help for that command.\n"},
|
" an argument, displays help for that command.\n"},
|
||||||
{"hexout", cmd_hexout,
|
{"hexout", cmd_hexout,
|
||||||
"hexout <address> <length> <filename.hex>\n"
|
"hexout <address> <length> <filename.hex>\n"
|
||||||
" Save a region of memory into an HEX file.\n"},
|
" Save a region of memory into a HEX file.\n"},
|
||||||
{"md", cmd_md,
|
{"md", cmd_md,
|
||||||
"md <address> <length>\n"
|
"md <address> <length>\n"
|
||||||
" Read the specified number of bytes from memory at the given address,\n"
|
" Read the specified number of bytes from memory at the given address,\n"
|
||||||
|
@ -633,8 +633,9 @@ static const struct command all_commands[] = {
|
||||||
"nosyms\n"
|
"nosyms\n"
|
||||||
" Clear the symbol table.\n"},
|
" Clear the symbol table.\n"},
|
||||||
{"prog", cmd_prog,
|
{"prog", cmd_prog,
|
||||||
"prog <filename.hex>\n"
|
"prog <filename>\n"
|
||||||
" Erase the device and flash the data contained in a binary file.\n"},
|
" Erase the device and flash the data contained in a binary file. This\n"
|
||||||
|
" command also loads symbols from the file, if available.\n"},
|
||||||
{"regs", cmd_regs,
|
{"regs", cmd_regs,
|
||||||
"regs\n"
|
"regs\n"
|
||||||
" Read and display the current register contents.\n"},
|
" Read and display the current register contents.\n"},
|
||||||
|
@ -682,11 +683,40 @@ static int cmd_help(char **arg)
|
||||||
fputs(cmd->help, stdout);
|
fputs(cmd->help, stdout);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
int max_len = 0;
|
||||||
|
int rows, cols;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LEN(all_commands); i++) {
|
||||||
|
int len = strlen(all_commands[i].name);
|
||||||
|
|
||||||
|
if (len > max_len)
|
||||||
|
max_len = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_len += 2;
|
||||||
|
cols = 72 / max_len;
|
||||||
|
rows = (ARRAY_LEN(all_commands) + cols - 1) / cols;
|
||||||
|
|
||||||
|
printf("Available commands:\n");
|
||||||
|
for (i = 0; i < rows; i++) {
|
||||||
|
int j;
|
||||||
|
|
||||||
|
printf(" ");
|
||||||
|
for (j = 0; j < cols; j++) {
|
||||||
|
int k = j * rows + i;
|
||||||
|
const struct command *cmd = &all_commands[k];
|
||||||
|
|
||||||
|
if (k >= ARRAY_LEN(all_commands))
|
||||||
|
break;
|
||||||
|
|
||||||
|
printf("%s", cmd->name);
|
||||||
|
for (k = strlen(cmd->name); k < max_len; k++)
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
printf("Available commands:");
|
|
||||||
for (i = 0; i < ARRAY_LEN(all_commands); i++)
|
|
||||||
printf(" %s", all_commands[i].name);
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("Type \"help <command>\" for more information.\n");
|
printf("Type \"help <command>\" for more information.\n");
|
||||||
printf("Press Ctrl+D to quit.\n");
|
printf("Press Ctrl+D to quit.\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue