shell: don't print colon if there's no item help
If the item has name but no help, there's no need to fill shell with tabulators and colon at the end of the line. Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit is contained in:
parent
c2f9e2b0d5
commit
08c41e7e4f
1 changed files with 9 additions and 5 deletions
|
@ -119,23 +119,27 @@ static void help_item_print(const struct shell *shell, const char *item_name,
|
|||
if (!IS_ENABLED(CONFIG_NEWLIB_LIBC) &&
|
||||
!IS_ENABLED(CONFIG_ARCH_POSIX)) {
|
||||
/* print option name */
|
||||
z_shell_fprintf(shell, SHELL_NORMAL, "%s%-*s%s:", tabulator,
|
||||
item_name_width, item_name, tabulator);
|
||||
z_shell_fprintf(shell, SHELL_NORMAL, "%s%-*s", tabulator,
|
||||
item_name_width, item_name);
|
||||
} else {
|
||||
uint16_t tmp = item_name_width - strlen(item_name);
|
||||
char space = ' ';
|
||||
|
||||
z_shell_fprintf(shell, SHELL_NORMAL, "%s%s", tabulator,
|
||||
item_name);
|
||||
for (uint16_t i = 0; i < tmp; i++) {
|
||||
z_shell_write(shell, &space, 1);
|
||||
|
||||
if (item_help) {
|
||||
for (uint16_t i = 0; i < tmp; i++) {
|
||||
z_shell_write(shell, &space, 1);
|
||||
}
|
||||
}
|
||||
z_shell_fprintf(shell, SHELL_NORMAL, "%s:", tabulator);
|
||||
}
|
||||
|
||||
if (item_help == NULL) {
|
||||
z_cursor_next_line_move(shell);
|
||||
return;
|
||||
} else {
|
||||
z_shell_fprintf(shell, SHELL_NORMAL, "%s:", tabulator);
|
||||
}
|
||||
/* print option help */
|
||||
formatted_text_print(shell, item_help, offset, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue