From: Lennart Poettering Date: Thu, 21 Jan 2021 16:39:01 +0000 (+0100) Subject: busctl/homectl: port the obvious cases to table_print_with_pager() X-Git-Tag: v248-rc1~276^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=665ffc7fba3222271ccce2b7e010663a3bfe4533;p=thirdparty%2Fsystemd.git busctl/homectl: port the obvious cases to table_print_with_pager() --- diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 276cae1b8b5..15e855062fd 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -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) { diff --git a/src/home/homectl.c b/src/home/homectl.c index f9c07dfec71..93d322110b5 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -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)) {