Merge pull request #30628 from YHNdnzj/format-table-improvement
Some improvements for format-table
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user