1 /*
2 main.cpp
3
4 This file is part of Charm, a task-based time tracking application.
5
6 Copyright (C) 2008-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
7
8 Author: Mirko Boehm <mirko.boehm@kdab.com>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 /* This program adds or removes timesheet XML files to and from an SQL
25 * database.
26 */
27 #include <iostream>
28
29 #include <QObject>
30
31 #include "CommandLine.h"
32 #include "Exceptions.h"
33 #include "Operations.h"
34 #include "CharmCMake.h"
35
main(int argc,char ** argv)36 int main(int argc, char **argv)
37 {
38 using namespace std;
39
40 try
41 {
42 CommandLine cmd(argc, argv);
43
44 switch (cmd.mode()) {
45 case CommandLine::Mode_InitializeDatabase:
46 initializeDatabase(cmd);
47 break;
48 case CommandLine::Mode_CheckOrCreateUser:
49 checkOrCreateUser(cmd);
50 break;
51 case CommandLine::Mode_AddTimesheet:
52 addTimesheet(cmd);
53 break;
54 case CommandLine::Mode_RemoveTimesheet:
55 removeTimesheet(cmd);
56 break;
57 case CommandLine::Mode_ExportProjectcodes:
58 exportProjectcodes(cmd);
59 break;
60 case CommandLine::Mode_PrintVersion:
61 cout << CHARM_VERSION << endl;
62 break;
63 case CommandLine::Mode_DescribeUsage:
64 default:
65 CommandLine::usage();
66 return 0;
67 }
68 } catch (const UsageException &e) {
69 cerr << e.what() << endl;
70 CommandLine::usage();
71 return 1;
72 } catch (const TimesheetProcessorException &e) {
73 cerr << e.what() << endl;
74 CommandLine::usage();
75 return 1;
76 }
77
78 return 0;
79 }
80