Skip to content

Commit d5c8d82

Browse files
committed
busctl: add introspect --xml-interface
This wraps the call to org.freedesktop.DBus.Introspectable.Introspect. Using "busctl call" directly is inconvenient because busctl escapes the string before printing. Example: $ busctl introspect --xml org.freedesktop.systemd1 /org/freedesktop/systemd1 | pygmentize -lxml | less -RF
1 parent d603324 commit d5c8d82

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

man/busctl.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@
140140
</listitem>
141141
</varlistentry>
142142

143+
<varlistentry>
144+
<term><option>--xml-interface</option></term>
145+
146+
<listitem>
147+
<para>When used with the <command>introspect</command> call, dump the XML description received from
148+
the D-Bus <constant>org.freedesktop.DBus.Introspectable.Introspect</constant> call instead of the
149+
normal output.</para>
150+
</listitem>
151+
</varlistentry>
152+
143153
<varlistentry>
144154
<term><option>--json=</option><replaceable>MODE</replaceable></term>
145155

src/busctl/busctl.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static size_t arg_snaplen = 4096;
5050
static bool arg_list = false;
5151
static bool arg_quiet = false;
5252
static bool arg_verbose = false;
53+
static bool arg_xml_interface = false;
5354
static bool arg_expect_reply = true;
5455
static bool arg_auto_start = true;
5556
static bool arg_allow_interactive_authorization = true;
@@ -948,6 +949,12 @@ static int introspect(int argc, char **argv, void *userdata) {
948949
if (r < 0)
949950
return bus_log_parse_error(r);
950951

952+
if (arg_xml_interface) {
953+
/* Just dump the received XML and finish */
954+
puts(xml);
955+
return 0;
956+
}
957+
951958
/* First, get list of all properties */
952959
r = parse_xml_introspect(argv[2], xml, &ops, members);
953960
if (r < 0)
@@ -2255,6 +2262,7 @@ static int parse_argv(int argc, char *argv[]) {
22552262
ARG_SIZE,
22562263
ARG_LIST,
22572264
ARG_VERBOSE,
2265+
ARG_XML_INTERFACE,
22582266
ARG_EXPECT_REPLY,
22592267
ARG_AUTO_START,
22602268
ARG_ALLOW_INTERACTIVE_AUTHORIZATION,
@@ -2284,6 +2292,7 @@ static int parse_argv(int argc, char *argv[]) {
22842292
{ "list", no_argument, NULL, ARG_LIST },
22852293
{ "quiet", no_argument, NULL, 'q' },
22862294
{ "verbose", no_argument, NULL, ARG_VERBOSE },
2295+
{ "xml-interface", no_argument, NULL, ARG_XML_INTERFACE },
22872296
{ "expect-reply", required_argument, NULL, ARG_EXPECT_REPLY },
22882297
{ "auto-start", required_argument, NULL, ARG_AUTO_START },
22892298
{ "allow-interactive-authorization", required_argument, NULL, ARG_ALLOW_INTERACTIVE_AUTHORIZATION },
@@ -2388,6 +2397,10 @@ static int parse_argv(int argc, char *argv[]) {
23882397
arg_verbose = true;
23892398
break;
23902399

2400+
case ARG_XML_INTERFACE:
2401+
arg_xml_interface = true;
2402+
break;
2403+
23912404
case ARG_EXPECT_REPLY:
23922405
r = parse_boolean(optarg);
23932406
if (r < 0)

0 commit comments

Comments
 (0)