File: main.cpp

package info (click to toggle)
dc-qt 0.2.0.alpha-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,948 kB
  • ctags: 5,361
  • sloc: cpp: 28,936; makefile: 19
file content (54 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (4)
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
#include "mainwindow.h"
#include "filelog.h"

#include "rpcdriver/rpcdriver.h"

#include <QApplication>
#include <QMessageBox>

#include <string>
#include <iostream>
#include <boost/program_options.hpp>
namespace opt = boost::program_options;

using std::string;

Log* logger = new FileLog;

int main(int argc, char *argv[])
{
	opt::options_description desc("Allowed options");
	desc.add_options()
		("help", 
		 "Display help message")
		("addr", 
		 opt::value<string>()->default_value("localhost"),
		 "Address to connect to")
		("port", 
		 opt::value<int>()->default_value(6161), 
		 "Specify port");
	
	opt::variables_map vm;
	
	try {
		opt::store(opt::parse_command_line(argc, argv, desc), vm);
	}
	catch( const opt::unknown_option& e ) {
		std::cerr << "Invalid option " << e.what() << std::endl;
	}
	
	if(vm.count("help")) {
		std::cout << desc << std::endl;
		return 1;
	}
	
	QApplication app(argc, argv);
	MainWindow *mw = new MainWindow;
	
	mw->show();
	//mw->connectToBackend(vm["addr"].as<string>().c_str(), port);
	// TODO use the above function instead if parameters was actually given -> overrides settings.
	mw->connectToBackend();
	return app.exec();
}