mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 10:36:34 +00:00
Added better handling for command line parameters
This commit is contained in:
+17
-9
@@ -1,3 +1,4 @@
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
#include "config.hpp"
|
||||
@@ -9,17 +10,24 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
SerialCommand serialCommand;
|
||||
SerialPort serialPort;
|
||||
Config::setInitalValues(&serialPort, &serialCommand);
|
||||
|
||||
QCommandLineParser parser;
|
||||
QCommandLineOption lOption(QStringList() << "l", "Use local mode");
|
||||
parser.addOption(lOption);
|
||||
QCommandLineOption pOption(QStringList() << "p", "Use serial port", "value");
|
||||
parser.addOption(pOption);
|
||||
parser.process(app);
|
||||
bool useRemoteMode = true;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (QString(argv[i]) == "-l") {
|
||||
useRemoteMode = false;
|
||||
break;
|
||||
}
|
||||
if (parser.isSet(lOption)) {
|
||||
useRemoteMode = false;
|
||||
}
|
||||
QString useSerialPort;
|
||||
if (parser.isSet(pOption)) {
|
||||
useSerialPort = parser.value(pOption);
|
||||
}
|
||||
|
||||
SerialCommand serialCommand;
|
||||
SerialPort serialPort(useSerialPort);
|
||||
Config::setInitalValues(&serialPort, &serialCommand);
|
||||
|
||||
// Remote mode will read commands from pipe
|
||||
if (useRemoteMode == true) {
|
||||
|
||||
Reference in New Issue
Block a user