Convert more programs to the new option and verb parsers (#41458)

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-04 10:21:14 +02:00
committed by GitHub
51 changed files with 366 additions and 419 deletions
+15 -3
View File
@@ -2221,7 +2221,7 @@ int _table_sync_column_widths(size_t column, Table *a, ...) {
return r;
}
int table_print(Table *t, FILE *f) {
int table_print_full(Table *t, FILE *f, bool flush) {
size_t n_rows, *minimum_width, *maximum_width, display_columns, *requested_width,
table_minimum_width, table_maximum_width, table_requested_width, table_effective_width,
*width = NULL;
@@ -2641,9 +2641,21 @@ int table_print(Table *t, FILE *f) {
} while (more_sublines);
}
if (!flush)
return 0;
return fflush_and_check(f);
}
int table_print_or_warn(Table *t) {
int r;
r = table_print(t);
if (r < 0)
return table_log_print_error(r);
return 0;
}
int table_format(Table *t, char **ret) {
_cleanup_(memstream_done) MemStream m = {};
FILE *f;
@@ -2656,7 +2668,7 @@ int table_format(Table *t, char **ret) {
if (!f)
return -ENOMEM;
r = table_print(t, f);
r = table_print_full(t, f, /* flush= */ true);
if (r < 0)
return r;
@@ -3145,7 +3157,7 @@ int table_print_json(Table *t, FILE *f, sd_json_format_flags_t flags) {
assert(t);
if (!sd_json_format_enabled(flags)) /* If JSON output is turned off, use regular output */
return table_print(t, f);
return table_print_full(t, f, /* flush= */ true);
if (!f)
f = stdout;