summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-01-10 11:41:28 +0000
committerHans Petter Jansson <hpj@hpjansson.org>2023-05-22 17:32:26 +0000
commite966d55382e34609a6ab6b9a4200eb5a9dcf05fa (patch)
tree42823e15b16f876e2418f989ef44cc1e5bf6cd56
parent8818dac847ce50794d8fd03659d3c93d8310adbc (diff)
Add --version
-rw-r--r--src/install.c15
-rw-r--r--src/update-desktop-database.c11
-rw-r--r--src/validator.c8
3 files changed, 33 insertions, 1 deletions
diff --git a/src/install.c b/src/install.c
index 915ed58..fa019b6 100644
--- a/src/install.c
+++ b/src/install.c
@@ -43,6 +43,7 @@ static gboolean edit_mode = FALSE;
static const char** args = NULL;
static gboolean delete_original = FALSE;
static gboolean rebuild_mime_info_cache = FALSE;
+static gboolean print_version = FALSE;
static char *vendor_name = NULL;
static char *target_dir = NULL;
static GSList *edit_actions = NULL;
@@ -319,6 +320,15 @@ static const GOptionEntry main_options[] = {
NULL
},
{
+ "version",
+ '\0',
+ '\0',
+ G_OPTION_ARG_NONE,
+ &print_version,
+ N_("Show the program version"),
+ NULL
+ },
+ {
"edit-mode",
'\0',
G_OPTION_FLAG_HIDDEN, /* just for development purpose */
@@ -887,6 +897,11 @@ main (int argc, char **argv)
return 1;
}
+ if (print_version) {
+ g_print("desktop-file-install %s\n", VERSION);
+ return 0;
+ }
+
if (!edit_mode)
{
if (vendor_name == NULL && g_getenv ("DESKTOP_FILE_VENDOR"))
diff --git a/src/update-desktop-database.c b/src/update-desktop-database.c
index 5a8dc56..4a89017 100644
--- a/src/update-desktop-database.c
+++ b/src/update-desktop-database.c
@@ -65,7 +65,7 @@ static const char ** get_default_search_path (void);
static void print_desktop_dirs (const char **dirs);
static GHashTable *mime_types_map = NULL;
-static gboolean verbose = FALSE, quiet = FALSE;
+static gboolean verbose = FALSE, quiet = FALSE, print_version = FALSE;
static void
list_free_deep (gpointer key, GList *l, gpointer data)
@@ -446,6 +446,10 @@ main (int argc,
N_("Display more information about processing and updating progress"),
NULL},
+ { "version", 0, 0, G_OPTION_ARG_NONE, &print_version,
+ N_("Show the program version"),
+ NULL},
+
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &desktop_dirs,
NULL, N_("[DIRECTORY...]") },
{ NULL }
@@ -473,6 +477,11 @@ main (int argc,
return 1;
}
+ if (print_version) {
+ g_print("update-desktop-database %s\n", VERSION);
+ return 0;
+ }
+
if (desktop_dirs == NULL || desktop_dirs[0] == NULL)
desktop_dirs = get_default_search_path ();
diff --git a/src/validator.c b/src/validator.c
index 151d507..69766ae 100644
--- a/src/validator.c
+++ b/src/validator.c
@@ -26,6 +26,7 @@
* USA.
*/
+#include <config.h>
#include <locale.h>
#ifdef HAVE_PLEDGE
@@ -37,12 +38,14 @@
static gboolean warn_kde = FALSE;
static gboolean no_hints = FALSE;
static gboolean no_warn_deprecated = FALSE;
+static gboolean print_version = FALSE;
static char **filename = NULL;
static GOptionEntry option_entries[] = {
{ "no-hints", 0, 0, G_OPTION_ARG_NONE, &no_hints, "Do not output hints to improve desktop file", NULL },
{ "no-warn-deprecated", 0, 0, G_OPTION_ARG_NONE, &no_warn_deprecated, "Do not warn about usage of deprecated items", NULL },
{ "warn-kde", 0, 0, G_OPTION_ARG_NONE, &warn_kde, "Warn if KDE extensions to the specification are used", NULL },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &print_version, "Show the program version", NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filename, NULL, "<desktop-file>..." },
{ NULL }
};
@@ -83,6 +86,11 @@ main (int argc, char *argv[])
g_option_context_free (context);
+ if (print_version) {
+ g_print("desktop-file-validate %s\n", VERSION);
+ return 0;
+ }
+
if (filename == NULL || filename[0] == NULL) {
g_printerr ("See \"%s --help\" for correct usage.\n", g_get_prgname ());
return 1;