client: Output a long message by two lines

This outputs the help message by two lines as follows if the string of
a command and a argument is long.

  set-alias <alias>          Set device alias
  select-attribute <attribute/UUID>
                             Select attribute
  attribute-info [attribute/UUID]
                             Select attribute
  read                       Read attribute value
This commit is contained in:
ERAMOTO Masaya 2017-06-19 20:26:36 +09:00 committed by Luiz Augusto von Dentz
parent 090e626a74
commit de4786090f

View File

@ -2262,10 +2262,18 @@ static void cmd_help(const char *arg)
printf("Available commands:\n");
for (i = 0; cmd_table[i].cmd; i++) {
printf(" %s %-*s %s\n", cmd_table[i].cmd,
if ((int)strlen(cmd_table[i].arg? : "") <=
(int)(25 - strlen(cmd_table[i].cmd)))
printf(" %s %-*s %s\n", cmd_table[i].cmd,
(int)(25 - strlen(cmd_table[i].cmd)),
cmd_table[i].arg ? : "",
cmd_table[i].desc ? : "");
else
printf(" %s %-s\n" " %s %-25s %s\n",
cmd_table[i].cmd,
cmd_table[i].arg ? : "",
"", "",
cmd_table[i].desc ? : "");
}
}