[four-in-a-row] Add --version command-line support.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [four-in-a-row] Add --version command-line support.
- Date: Fri, 27 Dec 2019 16:10:37 +0000 (UTC)
commit 49f2381d30e03a679faa93d054abc1b946ba0138
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Dec 26 22:09:13 2019 +0100
Add --version command-line support.
meson.build | 13 ++++++++-----
src/four-in-a-row.vala | 22 ++++++++++++++++++++++
src/meson.build | 1 +
3 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index cb03e1c..c118943 100644
--- a/meson.build
+++ b/meson.build
@@ -15,11 +15,14 @@ python3 = import('python3')
application_id = 'org.gnome.Four-in-a-row'
-gio_dependency = dependency('gio-2.0', version: '>= 2.40.0')
-glib_dependency = dependency('glib-2.0', version: '>= 2.40.0')
-gsound_dependency = dependency('gsound', version: '>= 1.0.2')
-gtk_dependency = dependency('gtk+-3.0', version: '>= 3.13.2')
-rsvg_dependency = dependency('librsvg-2.0', version: '>= 2.32.0')
+valac = meson.get_compiler('vala')
+
+gio_dependency = dependency('gio-2.0', version: '>= 2.40.0')
+glib_dependency = dependency('glib-2.0', version: '>= 2.40.0')
+gsound_dependency = dependency('gsound', version: '>= 1.0.2')
+gtk_dependency = dependency('gtk+-3.0', version: '>= 3.13.2')
+posix_dependency = valac.find_library('posix')
+rsvg_dependency = dependency('librsvg-2.0', version: '>= 2.32.0')
appstream_util = find_program('appstream-util', required: false)
desktop_file_validate = find_program('desktop-file-validate', required: false)
diff --git a/src/four-in-a-row.vala b/src/four-in-a-row.vala
index d0ae0e4..c16ad2d 100644
--- a/src/four-in-a-row.vala
+++ b/src/four-in-a-row.vala
@@ -89,6 +89,13 @@ private class FourInARow : Gtk.Application
[CCode (notify = false)] internal bool sound_on { private get; internal set; }
private uint8 theme_id;
+ private const OptionEntry [] option_entries =
+ {
+ /* Translators: command-line option description, see 'four-in-a-row --help' */
+ { "version", 'v', OptionFlags.NONE, OptionArg.NONE, null, N_("Print release version and exit"), null
},
+ {}
+ };
+
private const GLib.ActionEntry app_entries [] = // see also add_actions()
{
{ "game-type", null, "s", "'dark'", change_game_type },
@@ -121,6 +128,21 @@ private class FourInARow : Gtk.Application
private FourInARow ()
{
Object (application_id: "org.gnome.Four-in-a-row", flags: ApplicationFlags.FLAGS_NONE);
+
+ add_main_option_entries (option_entries);
+ }
+
+ protected override int handle_local_options (GLib.VariantDict options)
+ {
+ if (options.contains ("version"))
+ {
+ /* NOTE: Is not translated so can be easily parsed */
+ stdout.printf ("%1$s %2$s\n", "four-in-a-row", VERSION);
+ return Posix.EXIT_SUCCESS;
+ }
+
+ /* Activate */
+ return -1;
}
protected override void startup ()
diff --git a/src/meson.build b/src/meson.build
index ddf22aa..f0084ca 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -41,6 +41,7 @@ executable(
glib_dependency,
gsound_dependency,
gtk_dependency,
+ posix_dependency,
rsvg_dependency
],
c_args: [
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]