[packagekit] [PATCH 2/2] Add --version option for commands
James Bowes
jbowes at dangerouslyinc.com
Wed Oct 10 19:32:32 PDT 2007
Also hook up --verbose in cases where debug_init was always TRUE
before.
---
src/pk-application-main.c | 11 ++++++++++-
src/pk-backend-status.c | 9 +++++++++
src/pk-install-file.c | 19 ++++++++++++++++++-
src/pk-install-package.c | 19 ++++++++++++++++++-
src/pk-prefs.c | 9 +++++++++
src/pk-transaction-viewer.c | 9 +++++++++
src/pk-update-icon.c | 9 +++++++++
src/pk-update-viewer.c | 9 +++++++++
8 files changed, 91 insertions(+), 3 deletions(-)
diff --git a/src/pk-application-main.c b/src/pk-application-main.c
index f2224c7..c55d553 100644
--- a/src/pk-application-main.c
+++ b/src/pk-application-main.c
@@ -66,13 +66,16 @@ main (int argc, char *argv[])
{
GMainLoop *loop;
gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
PkApplication *application = NULL;
GOptionContext *context;
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
"Show extra debugging information", NULL },
- { NULL}
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
+ { NULL}
};
if (! g_thread_supported ()) {
@@ -85,6 +88,12 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
pk_debug_init (verbose);
gtk_init (&argc, &argv);
diff --git a/src/pk-backend-status.c b/src/pk-backend-status.c
index eec4391..5b39c2d 100644
--- a/src/pk-backend-status.c
+++ b/src/pk-backend-status.c
@@ -67,12 +67,15 @@ main (int argc, char *argv[])
{
GMainLoop *loop;
gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
GOptionContext *context;
GtkWidget *widget;
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
"Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
{ NULL}
};
@@ -86,6 +89,12 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
pk_debug_init (verbose);
gtk_init (&argc, &argv);
diff --git a/src/pk-install-file.c b/src/pk-install-file.c
index 6bc0475..9790db0 100644
--- a/src/pk-install-file.c
+++ b/src/pk-install-file.c
@@ -53,6 +53,16 @@ main (int argc, char *argv[])
{
GOptionContext *context;
gboolean ret;
+ gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
+
+ const GOptionEntry options[] = {
+ { "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
+ "Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
+ { NULL}
+ };
if (! g_thread_supported ()) {
g_thread_init (NULL);
@@ -62,9 +72,16 @@ main (int argc, char *argv[])
g_set_application_name (_("PackageKit File Installer"));
context = g_option_context_new (_("PackageKit File Installer"));
+ g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
- pk_debug_init (TRUE);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
+ pk_debug_init (verbose);
gtk_init (&argc, &argv);
if (argc < 2) {
diff --git a/src/pk-install-package.c b/src/pk-install-package.c
index ab71d28..12f67ee 100644
--- a/src/pk-install-package.c
+++ b/src/pk-install-package.c
@@ -100,6 +100,16 @@ main (int argc, char *argv[])
{
GOptionContext *context;
gboolean ret;
+ gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
+
+ const GOptionEntry options[] = {
+ { "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
+ "Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
+ { NULL}
+ };
if (! g_thread_supported ()) {
g_thread_init (NULL);
@@ -109,9 +119,16 @@ main (int argc, char *argv[])
g_set_application_name (_("PackageKit Package Installer"));
context = g_option_context_new (_("PackageKit Package Installer"));
+ g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
- pk_debug_init (TRUE);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
+ pk_debug_init (verbose);
gtk_init (&argc, &argv);
if (argc < 2) {
diff --git a/src/pk-prefs.c b/src/pk-prefs.c
index c1b7fab..9d4a1c0 100644
--- a/src/pk-prefs.c
+++ b/src/pk-prefs.c
@@ -266,6 +266,7 @@ main (int argc, char *argv[])
{
GMainLoop *loop;
gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
GOptionContext *context;
GtkWidget *main_window;
GtkWidget *widget;
@@ -275,6 +276,8 @@ main (int argc, char *argv[])
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
"Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
{ NULL}
};
@@ -288,6 +291,12 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
pk_debug_init (verbose);
gtk_init (&argc, &argv);
diff --git a/src/pk-transaction-viewer.c b/src/pk-transaction-viewer.c
index 17d8dda..bb195ef 100644
--- a/src/pk-transaction-viewer.c
+++ b/src/pk-transaction-viewer.c
@@ -340,6 +340,7 @@ main (int argc, char *argv[])
{
GMainLoop *loop;
gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
GOptionContext *context;
GtkWidget *main_window;
GtkWidget *widget;
@@ -350,6 +351,8 @@ main (int argc, char *argv[])
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
"Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
{ NULL}
};
@@ -363,6 +366,12 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
pk_debug_init (verbose);
gtk_init (&argc, &argv);
diff --git a/src/pk-update-icon.c b/src/pk-update-icon.c
index 9206506..e670d99 100644
--- a/src/pk-update-icon.c
+++ b/src/pk-update-icon.c
@@ -43,6 +43,7 @@ main (int argc, char *argv[])
{
GMainLoop *loop;
gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
PkNotify *notify = NULL;
PkWatch *watch = NULL;
GOptionContext *context;
@@ -50,6 +51,8 @@ main (int argc, char *argv[])
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
"Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
{ NULL}
};
@@ -64,6 +67,12 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
pk_debug_init (verbose);
gtk_init (&argc, &argv);
diff --git a/src/pk-update-viewer.c b/src/pk-update-viewer.c
index 21f6f6a..79eaeee 100644
--- a/src/pk-update-viewer.c
+++ b/src/pk-update-viewer.c
@@ -260,6 +260,7 @@ main (int argc, char *argv[])
{
GMainLoop *loop;
gboolean verbose = FALSE;
+ gboolean program_version = FALSE;
GOptionContext *context;
GtkWidget *main_window;
GtkWidget *widget;
@@ -270,6 +271,8 @@ main (int argc, char *argv[])
const GOptionEntry options[] = {
{ "verbose", '\0', 0, G_OPTION_ARG_NONE, &verbose,
"Show extra debugging information", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show the program version and exit", NULL },
{ NULL}
};
@@ -283,6 +286,12 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
+
+ if (program_version) {
+ g_print (VERSION "\n");
+ return 0;
+ }
+
pk_debug_init (verbose);
gtk_init (&argc, &argv);
--
1.5.3.4.1155.gfe96ee
More information about the PackageKit
mailing list