/*
    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    MA 02110-1301  USA.
*/

#include "siweatherclientconfig.h"

#include "stationsregister.h"

#include <ecmdlineargs.h>
#include <ecmdlineoption.h>
#include <elibrary.h>

#include <QCoreApplication>
#include <QTimer>
#include <QTextStream>

#include <iostream>

int main ( int argc, char** argv )
{
	ECmdLineArgs *args = new ECmdLineArgs();
	EngSaS::CmdLineOptions cmdLineOptions;
	cmdLineOptions << new ECmdLineOption("[register]", "r", QObject::tr("Register new station"));

	foreach(ECmdLineOption *option, cmdLineOptions)
		args->add(option);

	// if --help or --version is used, init returns false
	// and outputs the help
	if(!args->init(argc, argv))
		return 1;

	QCoreApplication app(argc, argv);
	QString error;
	ELibrary::setupApplication(QString("SiWeatherStation"), QString(VERSION), error);

	if(args->isSet("register")){
		StationsRegister *stationsRegister = new StationsRegister();
		QTimer::singleShot(1, stationsRegister, SLOT(registerStation()));
	}
// 	else if(){
// 		
// 	}
	else{
		QTextStream stream(stdout);
		stream << "Please specify an option" << endl;
		return -2;
	}

	// allow to start the event loop before executing our code
	return app.exec();
}
