mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-01 20:45:42 -04:00
info: Make --show-metadata machine parseable
This is useful mainly to parse the keyfile, and is not very nice for pretty output.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Reference in New Issue
Block a user