mirror of git://sigrok.org/pulseview
Added --version option
This commit is contained in:
parent
cef18fc616
commit
f7951df4a1
|
@ -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}
|
||||
|
|
|
@ -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@
|
||||
|
|
21
main.cpp
21
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.";
|
||||
|
|
Loading…
Reference in New Issue