Blob Blame History Raw
From 6b8ba25bd3caf0065805197a3b10e2697164ae3b Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Thu, 29 Sep 2011 17:51:20 +0200
Subject: [PATCH 1/4] report-newt: add option to display version (rhbz#741590)

---
 src/report-newt/report-newt.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/report-newt/report-newt.c b/src/report-newt/report-newt.c
index b8cc020..b8dddbc 100644
--- a/src/report-newt/report-newt.c
+++ b/src/report-newt/report-newt.c
@@ -357,18 +357,29 @@ int main(int argc, char **argv)
     enum {
         OPT_o = 1 << 0, // report only
         OPT_r = 1 << 1,
+        OPT_V = 1 << 2,
     };
     /* Keep enum above and order of options below in sync! */
     struct options program_options[] = {
         OPT_BOOL('o', "report-only", NULL, _("Skip analyze steps, go through report steps only")),
         OPT_BOOL('d', "delete", NULL,      _("Remove DIR after reporting")),
+        OPT_BOOL('V', "version", NULL,     _("Display version and exit")),
         OPT_END()
     };
     unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
     argv += optind;
-    if (!argv[0] || argv[1] || !(opts & OPT_o)) /* zero or >1 arguments */
+    /* zero or >1 arguments with -o, or >0 arguments with -V */
+    if (!(opts & (OPT_o | OPT_V)) ||
+            ((opts & OPT_o) && (!argv[0] || argv[1])) ||
+            ((opts & OPT_V) && argv[0]))
         show_usage_and_die(program_usage_string, program_options);
 
+    if (opts & OPT_V)
+    {
+        printf("%s "VERSION"\n", g_progname);
+        return 0;
+    }
+
     dump_dir_name = argv[0];
 
     /* Get settings */
-- 
1.7.6.4