1 | /* |
2 | SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org> |
3 | SPDX-License-Identifier: LGPL-2.0-or-later |
4 | */ |
5 | |
6 | #include "../isocodescache_p.h" |
7 | |
8 | #include <QCommandLineParser> |
9 | #include <QCoreApplication> |
10 | |
11 | int main(int argc, char **argv) |
12 | { |
13 | QCoreApplication app(argc, argv); |
14 | |
15 | QCommandLineParser parser; |
16 | QCommandLineOption codeOpt(QStringLiteral("code" ), QStringLiteral("ISO code type to generate a cache for [3166-1, 3166-2]" ), QStringLiteral("code" )); |
17 | parser.addOption(commandLineOption: codeOpt); |
18 | QCommandLineOption inputOpt(QStringLiteral("input" ), QStringLiteral("Input ISO codes JSON file to generate the cache for." ), QStringLiteral("input" )); |
19 | parser.addOption(commandLineOption: inputOpt); |
20 | QCommandLineOption outputOpt(QStringLiteral("output" ), QStringLiteral("Generated cache file." ), QStringLiteral("output" )); |
21 | parser.addOption(commandLineOption: outputOpt); |
22 | parser.addHelpOption(); |
23 | parser.process(app); |
24 | |
25 | const QString code = parser.value(option: codeOpt); |
26 | const QString inputFile = parser.value(option: inputOpt); |
27 | const QString outputFile = parser.value(option: outputOpt); |
28 | |
29 | if (code == QLatin1String("3166-1" )) { |
30 | IsoCodesCache::createIso3166_1Cache(isoCodesPath: inputFile, cacheFilePath: outputFile); |
31 | } else if (code == QLatin1String("3166-2" )) { |
32 | IsoCodesCache::createIso3166_2Cache(isoCodesPath: inputFile, cacheFilePath: outputFile); |
33 | } else { |
34 | parser.showHelp(); |
35 | return 1; |
36 | } |
37 | |
38 | return 0; |
39 | } |
40 | |