-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
61 lines (51 loc) · 1.75 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* @licence app begin@
* Copyright (C) 2021 Alexander Wenzel
*
* This file is part of the DLT Multimeter project.
*
* \copyright This code is licensed under GPLv3.
*
* \author Alexander Wenzel <[email protected]>
*
* \file main.cpp
* @licence end@
*/
#include "dialog.h"
#include "version.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("alexmucde");
QCoreApplication::setOrganizationDomain("github.com");
QCoreApplication::setApplicationName("DLTMultimeter");
QCoreApplication::setApplicationVersion(DLT_MULTIMETER_VERSION);
QCommandLineParser parser;
parser.setApplicationDescription("Read values from a Multimeter in a test automation.");
const QCommandLineOption helpOption = parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("configuration", QCoreApplication::translate("main", "Configuration file."));
// Option Autostart
QCommandLineOption autostartOption("a", QCoreApplication::translate("main", "Autostart Communication"));
parser.addOption(autostartOption);
// Parse the Arguments
parser.process(a);
// Stop application if help is called
if(parser.isSet(helpOption))
return 1;
// set command line options
QString configuration;
if(parser.positionalArguments().size()>=1)
configuration = parser.positionalArguments().at(0);
qDebug() << "Option: configuration =" << configuration;
bool autostart= false;
autostart = parser.isSet(autostartOption);
qDebug() << "Option: -a =" << autostart;
// execute dialog
Dialog w(autostart,configuration);
w.show();
return a.exec();
}