From 6281c3a0f6026a77d68026c0e14c49b825fab2ef Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 8 Jan 2009 18:38:19 +0100 Subject: [PATCH] Add command line option to show version number --- src/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index b895b1c..5da7c86 100644 --- a/src/main.c +++ b/src/main.c @@ -53,9 +53,10 @@ static void disconnect_callback(DBusConnection *conn, void *user_data) static gchar *option_device = NULL; static gchar *option_plugin = NULL; static gboolean option_detach = TRUE; -static gboolean option_selftest = FALSE; static gboolean option_compat = FALSE; static gboolean option_debug = FALSE; +static gboolean option_selftest = FALSE; +static gboolean option_version = FALSE; static GOptionEntry options[] = { { "device", 'i', 0, G_OPTION_ARG_STRING, &option_device, @@ -65,12 +66,14 @@ static GOptionEntry options[] = { { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_detach, "Don't fork daemon to background" }, - { "selftest", 't', 0, G_OPTION_ARG_NONE, &option_selftest, - "Run self testing routines" }, { "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat, "Enable Network Manager compatibility" }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug, "Enable debug information output" }, + { "selftest", 't', 0, G_OPTION_ARG_NONE, &option_selftest, + "Run self testing routines" }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, + "Show version information and exit" }, { NULL }, }; @@ -101,6 +104,11 @@ int main(int argc, char *argv[]) g_option_context_free(context); + if (option_version == TRUE) { + printf("%s\n", VERSION); + exit(0); + } + if (option_detach == TRUE) { if (daemon(0, 0)) { perror("Can't start daemon"); -- 1.7.9.5