HV: Normalize hypervisor help output format

Normalize hypervisor help command output format, remove the 10 lines
limit for one screen, fix the misspelled words.

Tracked-On: #5112
Signed-off-by: Liu Long <long.liu@intel.com>
Reviewed-by: VanCutsem, Geoffroy <geoffroy.vancutsem@intel.com>
This commit is contained in:
Liu Long 2021-09-16 15:30:31 +08:00 committed by wenlingz
parent 0466d7055f
commit 2de395b6f6

View File

@ -495,21 +495,20 @@ void shell_init(void)
SHELL_CMD_MAX_LEN + 1U); SHELL_CMD_MAX_LEN + 1U);
} }
#define SHELL_ROWS 10 #define SHELL_ROWS 30
#define MAX_INDENT_LEN 16U #define MAX_OUTPUT_LEN 80
static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv)
{ {
uint16_t spaces;
struct shell_cmd *p_cmd = NULL; struct shell_cmd *p_cmd = NULL;
char space_buf[MAX_INDENT_LEN + 1];
char str[MAX_STR_SIZE];
char* help_str;
/* Print title */ /* Print title */
shell_puts("\r\nRegistered Commands:\r\n\r\n"); shell_puts("\r\nRegistered Commands:\r\n\r\n");
pr_dbg("shell: Number of registered commands = %u in %s\n", pr_dbg("shell: Number of registered commands = %u in %s\n",
p_shell->cmd_count, __func__); p_shell->cmd_count, __func__);
(void)memset(space_buf, ' ', sizeof(space_buf));
/* Proceed based on the number of registered commands. */ /* Proceed based on the number of registered commands. */
if (p_shell->cmd_count == 0U) { if (p_shell->cmd_count == 0U) {
/* No registered commands */ /* No registered commands */
@ -539,29 +538,30 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv)
} }
i++; i++;
if (p_cmd->cmd_param == NULL)
/* Output the command string */ p_cmd->cmd_param = " ";
shell_puts(" "); (void)memset(str, ' ', sizeof(str));
shell_puts(p_cmd->str); /* Output the command & parameter string */
snprintf(str, MAX_OUTPUT_LEN, " %-15s%-64s",
/* Calculate spaces needed for alignment */ p_cmd->str, p_cmd->cmd_param);
spaces = MAX_INDENT_LEN - strnlen_s(p_cmd->str, MAX_INDENT_LEN - 1); shell_puts(str);
space_buf[spaces] = '\0';
shell_puts(space_buf);
space_buf[spaces] = ' ';
/* Display parameter info if applicable. */
if (p_cmd->cmd_param != NULL) {
shell_puts(p_cmd->cmd_param);
}
/* Display help text if available. */
if (p_cmd->help_str != NULL) {
shell_puts(" - ");
shell_puts(p_cmd->help_str);
}
shell_puts("\r\n"); shell_puts("\r\n");
help_str = p_cmd->help_str;
while (strnlen_s(help_str, MAX_OUTPUT_LEN > 0)) {
(void)memset(str, ' ', sizeof(str));
if (strnlen_s(help_str, MAX_OUTPUT_LEN) > 65) {
snprintf(str, MAX_OUTPUT_LEN, " %-s", help_str);
shell_puts(str);
shell_puts("\r\n");
help_str = help_str + 65;
} else {
snprintf(str, MAX_OUTPUT_LEN, " %-s", help_str);
shell_puts(str);
shell_puts("\r\n");
break;
}
}
} }
} }