summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-02-22 13:23:25 -0500
committerZenWalker <[email protected]>2019-03-06 02:13:56 +0100
commit0c11e1fb8004c5d8ce1147ce64f4d4bdcecc44ad (patch)
tree52c4602e06770505350ce78d68bf8fd6b37bc9ca
parentf1c0b177862e1760c849a9ea5d37041e27ede14d (diff)
downloadengrampa-0c11e1fb8004c5d8ce1147ce64f4d4bdcecc44ad.tar.bz2
engrampa-0c11e1fb8004c5d8ce1147ce64f4d4bdcecc44ad.tar.xz
Show version on command line
This adds a --version flag to the engrampa cli.
-rw-r--r--data/engrampa.13
-rw-r--r--src/main.c13
2 files changed, 16 insertions, 0 deletions
diff --git a/data/engrampa.1 b/data/engrampa.1
index f829c91..476a62a 100644
--- a/data/engrampa.1
+++ b/data/engrampa.1
@@ -63,6 +63,9 @@ Print standard command line options.
.TP
\fB\-\-help\-all\fR
Print all command line options.
+.TP
+\fB\-\-version\fR
+Show the application's version.
.P
This program also accepts the standard GTK options.
diff --git a/src/main.c b/src/main.c
index a66dba6..916d9e5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -43,6 +43,14 @@ static int extract;
static int extract_here;
static char *default_url = NULL;
+static gboolean
+_print_version_and_exit (const gchar *option_name, const gchar *value, gpointer data, GError *error)
+{
+ g_print("%s %s\n", _("Engrampa Archive Manager"), VERSION);
+ exit (EXIT_SUCCESS);
+ return TRUE;
+}
+
/* argv[0] from main(); used as the command to restart the program */
static const char *program_argv0 = NULL;
@@ -75,6 +83,11 @@ static const GOptionEntry options[] = {
N_("Create destination folder without asking confirmation"),
NULL },
+ { "version", 0, G_OPTION_FLAG_NO_ARG,
+ G_OPTION_ARG_CALLBACK, _print_version_and_exit,
+ N_("Show the application's version"),
+ NULL },
+
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,
NULL,
NULL },