KI18n

cachegen.cpp
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
11int 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(codeOpt);
18 QCommandLineOption inputOpt(QStringLiteral("input"), QStringLiteral("Input ISO codes JSON file to generate the cache for."), QStringLiteral("input"));
19 parser.addOption(inputOpt);
20 QCommandLineOption outputOpt(QStringLiteral("output"), QStringLiteral("Generated cache file."), QStringLiteral("output"));
21 parser.addOption(outputOpt);
22 parser.addHelpOption();
23 parser.process(app);
24
25 const QString code = parser.value(codeOpt);
26 const QString inputFile = parser.value(inputOpt);
27 const QString outputFile = parser.value(outputOpt);
28
29 if (code == QLatin1String("3166-1")) {
30 IsoCodesCache::createIso3166_1Cache(inputFile, outputFile);
31 } else if (code == QLatin1String("3166-2")) {
32 IsoCodesCache::createIso3166_2Cache(inputFile, outputFile);
33 } else {
34 parser.showHelp();
35 return 1;
36 }
37
38 return 0;
39}
QCommandLineOption addHelpOption()
bool addOption(const QCommandLineOption &option)
void process(const QCoreApplication &app)
void showHelp(int exitCode)
QString value(const QCommandLineOption &option) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.