File indexing completed on 2024-11-24 03:37:23

0001 /*
0002     SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #include "../isocodescache_p.h"
0007 
0008 #include <QCommandLineParser>
0009 #include <QCoreApplication>
0010 
0011 int main(int argc, char **argv)
0012 {
0013     QCoreApplication app(argc, argv);
0014 
0015     QCommandLineParser parser;
0016     QCommandLineOption codeOpt(QStringLiteral("code"), QStringLiteral("ISO code type to generate a cache for [3166-1, 3166-2]"), QStringLiteral("code"));
0017     parser.addOption(codeOpt);
0018     QCommandLineOption inputOpt(QStringLiteral("input"), QStringLiteral("Input ISO codes JSON file to generate the cache for."), QStringLiteral("input"));
0019     parser.addOption(inputOpt);
0020     QCommandLineOption outputOpt(QStringLiteral("output"), QStringLiteral("Generated cache file."), QStringLiteral("output"));
0021     parser.addOption(outputOpt);
0022     parser.addHelpOption();
0023     parser.process(app);
0024 
0025     const QString code = parser.value(codeOpt);
0026     const QString inputFile = parser.value(inputOpt);
0027     const QString outputFile = parser.value(outputOpt);
0028 
0029     if (code == QLatin1String("3166-1")) {
0030         IsoCodesCache::createIso3166_1Cache(inputFile, outputFile);
0031     } else if (code == QLatin1String("3166-2")) {
0032         IsoCodesCache::createIso3166_2Cache(inputFile, outputFile);
0033     } else {
0034         parser.showHelp();
0035         return 1;
0036     }
0037 
0038     return 0;
0039 }