Merge pull request #30628 from YHNdnzj/format-table-improvement

Some improvements for format-table
This commit is contained in:
Yu Watanabe
2023-12-25 20:01:32 +09:00
committed by GitHub
17 changed files with 63 additions and 47 deletions
+4 -4
View File
@@ -235,7 +235,7 @@ static int show_table(Table *table, const char *word) {
assert(table);
assert(word);
if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) {
if (!table_isempty(table) || OUTPUT_MODE_IS_JSON(arg_output)) {
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);
@@ -251,10 +251,10 @@ static int show_table(Table *table, const char *word) {
}
if (arg_legend) {
if (table_get_rows(table) > 1)
printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
else
if (table_isempty(table))
printf("No %s.\n", word);
else
printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
}
return 0;