-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
42 lines (35 loc) · 1.21 KB
/
main.cpp
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
#include "Worker.h"
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QFileInfo>
int main(int argc, char *argv[])
{
QCoreApplication::setApplicationName("QObject2TS");
QCoreApplication::setOrganizationName("jaredtao");
QCoreApplication::setOrganizationDomain("https://jaredtao.github.io");
QCoreApplication::setApplicationVersion("1.0.0");
QCoreApplication a(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription("convert QObject to typescript");
parser.addPositionalArgument("input", "input file path");
parser.addPositionalArgument("output", "output file path");
parser.addHelpOption();
parser.addVersionOption();
parser.process(a);
QString inputFile;
QString outputFile;
if (parser.positionalArguments().size() < 1) {
parser.showHelp();
}
inputFile = parser.positionalArguments().at(0);
if (parser.positionalArguments().size() > 1) {
parser.positionalArguments().at(1);
} else {
QFileInfo info(inputFile);
outputFile = info.absolutePath() + "/" + info.baseName() + ".ts";
}
Worker worker;
worker.work(inputFile, outputFile);
return 0;
}