]> sigrok.org Git - pulseview.git/commitdiff
Added --version option
authorJoel Holdsworth <redacted>
Fri, 12 Oct 2012 23:59:37 +0000 (00:59 +0100)
committerUwe Hermann <redacted>
Sat, 13 Oct 2012 13:02:58 +0000 (15:02 +0200)
CMakeLists.txt
config.h.in
main.cpp

index c6459353b62a63f19e757e10e93075961217cd6a..b6252fe91563de3b90d882e5a48365dfadfe8fd7 100644 (file)
@@ -58,6 +58,8 @@ find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
 #= Config Header
 #-------------------------------------------------------------------------------
 
+set(PV_TITLE PulseView)
+
 set(PV_VERSION_MAJOR 0)
 set(PV_VERSION_MINOR 1)
 set(PV_VERSION_MICRO 0)
@@ -186,7 +188,9 @@ install(PROGRAMS pulseview DESTINATION bin/)
 
 if(ENABLE_TESTS)
 
-       add_definitions(-DBOOST_TEST_DYN_LINK)
+       add_definitions(pulseview-tests
+               -DBOOST_TEST_DYN_LINK
+       )
 
        add_executable(pulseview-test
                ${pulseview_TEST_SOURCES}
index ea9b0d4ac0aa77fca1633602022a390824042f64..6caa2303f26ae78230c83d2cfd1d00d0e12fd6f3 100644 (file)
@@ -20,6 +20,9 @@
 #ifndef _PULSEVIEW_CONFIG_H
 #define _PULSEVIEW_CONFIG_H
 
+/* Application Details */
+#define PV_TITLE "@PV_TITLE@"
+
 /* Pulseview version information */
 #define PV_VERSION_MAJOR @PV_VERSION_MAJOR@
 #define PV_VERSION_MINOR @PV_VERSION_MINOR@
index febe729c4bc97d0ea25e095ada555525c8f062b2..a94f64c67b07b60b45cf2b96b5cb1fc264fbf8c6 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -24,6 +24,8 @@ extern "C" {
 #include <libsigrok/libsigrok.h>
 }
 
+#include <getopt.h>
+
 #include <QtGui/QApplication>
 #include <QDebug>
 
@@ -40,6 +42,25 @@ int main(int argc, char *argv[])
        QApplication::setApplicationName("PulseView");
        QApplication::setOrganizationDomain("http://www.sigrok.org");
 
+       // Parse arguments
+       while (1) {
+               static const struct option long_options[] = {
+                       {"version", no_argument, 0,  'V'},
+                       {0, 0, 0, 0}
+               };
+
+               const char c = getopt_long(argc, argv, "V", long_options, NULL);
+               if (c == -1)
+                       break;
+
+               switch (c) {
+               case 'V':
+                       // Print version info
+                       fprintf(stderr, "%s %s\n", PV_TITLE, PV_VERSION_STRING);
+                       return 0;
+               }
+       }
+
        // Initialise libsigrok
        if (sr_init() != SR_OK) {
                qDebug() << "ERROR: libsigrok init failed.";