summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-14 13:18:33 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-14 13:18:51 +0100
commit56c8b52d4dc652bf15aa8c2ef44d35b166b419c1 (patch)
treef751244cca9ac765e07d8d34636358f99c2d3545
parent86349ffe49092345269762e3274121133604c3d4 (diff)
busctl: various tweaks to "busctl tree" output
-rw-r--r--src/libsystemd/sd-bus/busctl.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index ea8425ac23..2bf890e88f 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -291,8 +291,15 @@ static void print_tree(const char *prefix, char **l) {
return;
}
- if (!strv_isempty(l))
- printf("%s/\n", prefix);
+ if (strv_isempty(l)) {
+ printf("No objects discovered.\n");
+ return;
+ }
+
+ if (streq(l[0], "/") && !l[1]) {
+ printf("Only root object discovered.\n");
+ return;
+ }
print_subtree(prefix, "/", l);
}
@@ -964,7 +971,7 @@ static int tree(sd_bus *bus, char **argv) {
if (strv_length(argv) <= 1) {
_cleanup_strv_free_ char **names = NULL;
- bool not_first = true;
+ bool not_first = false;
r = sd_bus_list_names(bus, &names, NULL);
if (r < 0) {
@@ -986,9 +993,9 @@ static int tree(sd_bus *bus, char **argv) {
if (not_first)
printf("\n");
- printf("Service %s:\n", *i);
+ printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_highlight_off());
- q = tree_one(bus, *i, "\t");
+ q = tree_one(bus, *i, NULL);
if (q < 0 && r >= 0)
r = q;
@@ -1004,7 +1011,7 @@ static int tree(sd_bus *bus, char **argv) {
printf("\n");
if (argv[2])
- printf("Service %s:\n", *i);
+ printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_highlight_off());
q = tree_one(bus, *i, NULL);
if (q < 0 && r >= 0)