glib-compile-resources: Add a --version option

There have been some improvements to the tool recently, but it's hard to
know if those are available on a given system unless the tool provides a
--version commandline option.

https://bugzilla.gnome.org/show_bug.cgi?id=772269
This commit is contained in:
Sam Thursfield 2016-09-30 22:56:16 +01:00
parent e048d31210
commit bce8b6db8d
2 changed files with 15 additions and 0 deletions

View File

@ -56,6 +56,13 @@ Print help and exit
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--version</option></term>
<listitem><para>
Print program version and exit
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--target=<replaceable>TARGET</replaceable></option></term>
<listitem><para>

View File

@ -603,6 +603,7 @@ main (int argc, char **argv)
GHashTable *table;
GHashTable *files;
gchar *srcfile;
gboolean show_version_and_exit = FALSE;
gchar *target = NULL;
gchar *binary_target = NULL;
gboolean generate_automatic = FALSE;
@ -617,6 +618,7 @@ main (int argc, char **argv)
const char *linkage = "extern";
GOptionContext *context;
GOptionEntry entries[] = {
{ "version", 0, 0, G_OPTION_ARG_NONE, &show_version_and_exit, N_("Show program version and exit"), NULL },
{ "target", 0, 0, G_OPTION_ARG_FILENAME, &target, N_("name of the output file"), N_("FILE") },
{ "sourcedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &sourcedirs, N_("The directories where files are to be read from (default to current directory)"), N_("DIRECTORY") },
{ "generate", 0, 0, G_OPTION_ARG_NONE, &generate_automatic, N_("Generate output in the format selected for by the target filename extension"), NULL },
@ -666,6 +668,12 @@ main (int argc, char **argv)
g_option_context_free (context);
if (show_version_and_exit)
{
g_print (PACKAGE_VERSION "\n");
return 0;
}
if (argc != 2)
{
g_printerr (_("You should give exactly one file name\n"));