summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-01-21 17:39:01 +0100
committerLennart Poettering <lennart@poettering.net>2021-01-21 18:14:21 +0100
commit665ffc7fba3222271ccce2b7e010663a3bfe4533 (patch)
treea07e327723049b0c6b6b1b2f8221056403541157 /src
parente676b4fc8bbf1e7e602d839721b092fd58aacc05 (diff)
downloadsystemd-665ffc7fba3222271ccce2b7e010663a3bfe4533.tar.gz
busctl/homectl: port the obvious cases to table_print_with_pager()
Diffstat (limited to 'src')
-rw-r--r--src/busctl/busctl.c11
-rw-r--r--src/home/homectl.c8
2 files changed, 3 insertions, 16 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index 276cae1b8b..15e855062f 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 f9c07dfec7..93d322110b 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)) {