From 504a3a25ea0dfdaa2fc8f3f929f7e0c7dc23da85 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 19 Jun 2017 10:58:09 +0200 Subject: [PATCH] info: Make --show-metadata machine parseable This is useful mainly to parse the keyfile, and is not very nice for pretty output. --- app/flatpak-builtins-info.c | 36 +++++++++++++++++------------------- doc/flatpak-info.xml | 2 +- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/flatpak-builtins-info.c b/app/flatpak-builtins-info.c index 9ab826e8..22368adb 100644 --- a/app/flatpak-builtins-info.c +++ b/app/flatpak-builtins-info.c @@ -149,7 +149,7 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError * metakey = flatpak_deploy_get_metadata (deploy); - if (opt_show_ref || opt_show_origin || opt_show_commit || opt_show_size) + if (opt_show_ref || opt_show_origin || opt_show_commit || opt_show_size || opt_show_metadata) friendly = FALSE; if (friendly) @@ -213,6 +213,22 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError * if (!first) g_print ("\n"); + + if (opt_show_metadata) + { + g_autoptr(GFile) deploy_dir = NULL; + g_autoptr(GFile) file = NULL; + g_autofree char *data = NULL; + gsize data_size; + + deploy_dir = flatpak_dir_get_if_deployed (dir, ref, NULL, cancellable); + file = g_file_get_child (deploy_dir, "metadata"); + + if (!g_file_load_contents (file, cancellable, &data, &data_size, NULL, error)) + return FALSE; + + g_print ("%s", data); + } } if (opt_show_extensions) @@ -264,24 +280,6 @@ flatpak_builtin_info (int argc, char **argv, GCancellable *cancellable, GError * } } - if (opt_show_metadata) - { - g_autoptr(GFile) deploy_dir = NULL; - g_autoptr(GFile) file = NULL; - g_autofree char *data = NULL; - gsize data_size; - - g_print ("\n%s%s%s\n", on, _("Metadata:"), off); - - deploy_dir = flatpak_dir_get_if_deployed (dir, ref, NULL, cancellable); - file = g_file_get_child (deploy_dir, "metadata"); - - if (!g_file_load_contents (file, cancellable, &data, &data_size, NULL, error)) - return FALSE; - - g_print ("%s\n", data); - } - return TRUE; } diff --git a/doc/flatpak-info.xml b/doc/flatpak-info.xml index 09baca21..e35e1e3a 100644 --- a/doc/flatpak-info.xml +++ b/doc/flatpak-info.xml @@ -46,7 +46,7 @@ By default, the output is formatted in a friendly format. If you specify one of the options --show-ref, --show-commit, - --show-origin or --show-size, the output is instead formatted + --show-origin, --show-metadata or --show-size, the output is instead formatted in a machine-readable format.