1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

loginctl: optionally output table in json

This works now:

  $ loginctl list-session --output=json-pretty
This commit is contained in:
Lennart Poettering 2018-12-03 20:46:33 +01:00
parent 31ac235771
commit e3483674ec

View File

@ -101,6 +101,9 @@ static int show_table(Table *table, const char *word) {
table_set_header(table, arg_legend);
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");
@ -1434,6 +1437,10 @@ 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: