1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-31 14:50:15 +03:00

busctl/homectl: port the obvious cases to table_print_with_pager()

This commit is contained in:
Lennart Poettering 2021-01-21 17:39:01 +01:00
parent e676b4fc8b
commit 665ffc7fba
2 changed files with 3 additions and 16 deletions

View File

@ -239,8 +239,6 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to set columns to display: %m");
table_set_header(table, arg_legend);
HASHMAP_FOREACH_KEY(v, k, names) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
@ -357,14 +355,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
return log_error_errno(r, "Failed to fill line: %m");
}
if (arg_json_format_flags & (JSON_FORMAT_OFF|JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO))
(void) pager_open(arg_pager_flags);
r = table_print_json(table, NULL, arg_json_format_flags);
if (r < 0)
return table_log_print_error(r);
return 0;
return table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
}
static void print_subtree(const char *prefix, const char *path, char **l) {

View File

@ -113,8 +113,6 @@ static int list_homes(int argc, char *argv[], void *userdata) {
_cleanup_(table_unrefp) Table *table = NULL;
int r;
(void) pager_open(arg_pager_flags);
r = acquire_bus(&bus);
if (r < 0)
return r;
@ -175,11 +173,9 @@ static int list_homes(int argc, char *argv[], void *userdata) {
if (r < 0)
return table_log_sort_error(r);
table_set_header(table, arg_legend);
r = table_print_json(table, stdout, arg_json_format_flags);
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0)
return table_log_print_error(r);
return r;
}
if (arg_legend && (arg_json_format_flags & JSON_FORMAT_OFF)) {