Skip to content

RFC: gdbus-tool: Add --color option for introspect

Niels De Graef requested to merge wip/nielsdg/gdbus-colorized-output into master

From the commit message:

When the `--color` option is used, gdbus will add colors to make it
easier for humans to parse the output. This is turned off by default to
make sure we don't mess up any parsing tools.

This use case for the MR is the following: if you have a graphical environment, one can use D-feet to play around with D-Bus interfaces. If you do not have this however, the site of D-feet itself recommends using gdbus for a nice command-line interface. As such, it seems fitting (and easier on the eye) to also provide distinguishable colors. Note that we also support the basic 16-bit terminal colors (inspiration taken from https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/40)

Questions remaining:

  • Is this feature wanted (hence the RFC)? If not, then we can just close this
  • Which colors do we use when and where? I intentionally left some macros to expand to RESET_COLOR to avoid a warning for the identical branches in "" : "", but this is just meant as a stop-gap until we figure out what we want to colorize and whatnot. We can remove the non-coloring macros later if wanted.
  • Is the approach in the code good? Maybe it can also be extended later for the other commands of gdbus?
  • Do we need to support more than 16 colors?
  • Do we put this on by default and add a --no-color instead?

Merge request reports