This repository was archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
75 lines (65 loc) · 2.16 KB
/
main.cpp
File metadata and controls
75 lines (65 loc) · 2.16 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QStandardPaths>
#include <QDir>
#include "converter.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.setApplicationName("pgserverconverter");
app.setApplicationVersion("1.0");
QCommandLineParser parser;
parser.setApplicationDescription("Convert saved pgadmin3 servers to pgadmin4 db entries");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption inputFile(QStringList() << "i" << "input",
#ifdef Q_OS_LINUX
QCoreApplication::translate("main", "pgadmin3 config file. Defaults to ~/.pgadmin3"),
#endif
#ifdef Q_OS_MAC
QCoreApplication::translate("main", "pgadmin3 config file. Defaults to ~/Library/Preferences/pgadmin3 Preferences"),
#endif
#ifdef Q_OS_WIN
QCoreApplication::translate("main", "pgadmin3 config file. Defaults to the windows registry"),
#endif
QCoreApplication::translate("main", "inputfile"));
parser.addOption(inputFile);
QCommandLineOption database(QStringList() << "d" << "database",
#ifdef Q_OS_WIN
QCoreApplication::translate("main", "Path to pgAdmin4's SQLite database. Defaults to ~/AppData/Roaming/pgadmin/pgadmin4.db"),
#else
QCoreApplication::translate("main", "Path to pgAdmin4's SQLite database. Defaults to ~/.pgadmin/pgadmin4.db"),
#endif
QCoreApplication::translate("main", "database"));
parser.addOption(database);
parser.process(app);
QString _input;
QString _db;
if (parser.isSet("input")) {
_input = parser.value("input");
}
else {
#ifdef Q_OS_LINUX
_input = QDir::homePath() + "/.pgadmin3";
#endif
#ifdef Q_OS_MAC
_input = QDir::homePath() + "/Library/Preferences/pgadmin3 Preferences";
#endif
#ifdef Q_OS_WIN
_input = "Windows Registry";
#endif
}
if (parser.isSet("database")) {
_db = parser.value("database");
}
else {
#ifdef Q_OS_WIN
_db = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)[0] + "/../pgadmin/pgadmin4.db";
#else
_db = QDir::homePath() + "/.pgadmin/pgadmin4.db";
#endif
}
converter c(_input, _db);
c.start();
return app.exec();
}