main: Make ostree --version output YAML (and add gitrev)

I learned today that `docker version` does this and I really like
the idea.  While we have the patient open, also add the gitrev
with code taken from https://github.com/projectatomic/rpm-ostree/pull/584

Closes: #691
Approved by: giuseppe
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-02-22 18:57:18 +00:00
1 parent 3ec509c89b
commit 09b392675a
7 files changed
+30 -10

No files matched your search

+10 -1
View File
@@ -241,7 +241,16 @@ ostree_option_context_parse (GOptionContext *context,
if (opt_version)
{
g_print ("%s\n %s\n", PACKAGE_STRING, OSTREE_FEATURES);
/* This should now be YAML, like `docker version`, so it's both nice to read
* possible to parse */
g_auto(GStrv) features = g_strsplit (OSTREE_FEATURES, " ", -1);
g_print ("%s:\n", PACKAGE_NAME);
g_print (" Version: %s\n", PACKAGE_VERSION);
if (strlen (OSTREE_GITREV) > 0)
g_print (" Git: %s\n", OSTREE_GITREV);
g_print (" Features:\n");
for (char **iter = features; iter && *iter; iter++)
g_print (" - %s\n", *iter);
exit (EXIT_SUCCESS);
}