| 1 | /*
|
|---|
| 2 | Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 3 |
|
|---|
| 4 | This library is free software; you can redistribute it and/or
|
|---|
| 5 | modify it under the terms of the GNU Lesser General Public
|
|---|
| 6 | License as published by the Free Software Foundation; either
|
|---|
| 7 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This library is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 12 | Lesser General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 15 | License along with this library; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|---|
| 17 | MA 02110-1301 USA.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | #include "siweatherclientconfig.h"
|
|---|
| 21 |
|
|---|
| 22 | #include "stationsregister.h"
|
|---|
| 23 |
|
|---|
| 24 | #include <ecmdlineargs.h>
|
|---|
| 25 | #include <ecmdlineoption.h>
|
|---|
| 26 | #include <elibrary.h>
|
|---|
| 27 |
|
|---|
| 28 | #include <QCoreApplication>
|
|---|
| 29 | #include <QTimer>
|
|---|
| 30 | #include <QTextStream>
|
|---|
| 31 |
|
|---|
| 32 | #include <iostream>
|
|---|
| 33 |
|
|---|
| 34 | int main ( int argc, char** argv )
|
|---|
| 35 | {
|
|---|
| 36 | ECmdLineArgs *args = new ECmdLineArgs();
|
|---|
| 37 | EngSaS::CmdLineOptions cmdLineOptions;
|
|---|
| 38 | cmdLineOptions << new ECmdLineOption("[register]", "r", QObject::tr("Register new station"));
|
|---|
| 39 |
|
|---|
| 40 | foreach(ECmdLineOption *option, cmdLineOptions)
|
|---|
| 41 | args->add(option);
|
|---|
| 42 |
|
|---|
| 43 | // if --help or --version is used, init returns false
|
|---|
| 44 | // and outputs the help
|
|---|
| 45 | if(!args->init(argc, argv))
|
|---|
| 46 | return 1;
|
|---|
| 47 |
|
|---|
| 48 | QCoreApplication app(argc, argv);
|
|---|
| 49 | QString error;
|
|---|
| 50 | ELibrary::setupApplication(QString("SiWeatherStation"), QString(VERSION), error);
|
|---|
| 51 |
|
|---|
| 52 | if(args->isSet("register")){
|
|---|
| 53 | StationsRegister *stationsRegister = new StationsRegister();
|
|---|
| 54 | QTimer::singleShot(1, stationsRegister, SLOT(registerStation()));
|
|---|
| 55 | }
|
|---|
| 56 | // else if(){
|
|---|
| 57 | //
|
|---|
| 58 | // }
|
|---|
| 59 | else{
|
|---|
| 60 | QTextStream stream(stdout);
|
|---|
| 61 | stream << "Please specify an option" << endl;
|
|---|
| 62 | return -2;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | // allow to start the event loop before executing our code
|
|---|
| 66 | return app.exec();
|
|---|
| 67 | }
|
|---|