summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-03 20:58:32 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-03 22:42:38 +0100
commitad9d139e023eb08144b79ba89914a91b8463b2ec (patch)
tree28ea2965c86b37434f83e88519d912e1e88fae45 /src/machine
parente3483674ec0c9507f2439a070bebaf1cead62e5d (diff)
downloadsystemd-ad9d139e023eb08144b79ba89914a91b8463b2ec.tar.gz
machinectl: optionally output table in JSON
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machinectl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 5023acb5e2..b7a604a55c 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -259,7 +259,10 @@ static int show_table(Table *table, const char *word) {
table_set_header(table, arg_legend);
- r = table_print(table, NULL);
+ if (OUTPUT_MODE_IS_JSON(arg_output))
+ r = table_print_json(table, NULL, output_mode_to_json_format_flags(arg_output) | JSON_FORMAT_COLOR_AUTO);
+ else
+ r = table_print(table, NULL);
if (r < 0)
return log_error_errno(r, "Failed to show table: %m");
}
@@ -2921,6 +2924,9 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_output < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Unknown output '%s'.", optarg);
+
+ if (OUTPUT_MODE_IS_JSON(arg_output))
+ arg_legend = false;
break;
case ARG_NO_PAGER: