File indexing completed on 2023-09-24 04:10:43

0001 /*
0002     SPDX-FileCopyrightText: 2008 Aaron Seigo <aseigo@kde.org>
0003     SPDX-FileCopyrightText: 2013 Sebastian K├╝gler <sebas@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 /**
0009  * kpackagetool5 exit codes used in this program
0010 
0011     0 No error
0012 
0013     1 Unspecified error
0014     2 Plugin is not installed
0015     3 Plugin or package invalid
0016     4 Installation failed, see stderr for reason
0017     5 Could not find a suitable installer for package type
0018     6 No install option given
0019     7 Conflicting arguments supplied
0020     8 Uninstallation failed, see stderr for reason
0021     9 Failed to generate package hash
0022 
0023 */
0024 
0025 #include <KLocalizedString>
0026 #include <QCommandLineParser>
0027 
0028 #include "kpackagetool.h"
0029 #include "options.h"
0030 
0031 int main(int argc, char **argv)
0032 {
0033     QCommandLineParser parser;
0034     KPackage::PackageTool app(argc, argv, &parser);
0035 
0036     const QString description = i18n("KPackage Manager");
0037     const auto version = QStringLiteral("2.0");
0038 
0039     app.setApplicationVersion(version);
0040     parser.addVersionOption();
0041     parser.addHelpOption();
0042     parser.setApplicationDescription(description);
0043     parser.addOptions({Options::hash(),
0044                        Options::global(),
0045                        Options::type(),
0046                        Options::install(),
0047                        Options::show(),
0048                        Options::upgrade(),
0049                        Options::list(),
0050                        Options::listTypes(),
0051                        Options::remove(),
0052                        Options::packageRoot(),
0053                        Options::generateIndex(),
0054                        Options::removeIndex(),
0055                        Options::appstream(),
0056                        Options::appstreamOutput()});
0057     parser.process(app);
0058 
0059     // at least one operation should be specified
0060     if (!parser.isSet(QStringLiteral("hash")) && !parser.isSet(QStringLiteral("g")) && !parser.isSet(QStringLiteral("i")) && !parser.isSet(QStringLiteral("s"))
0061         && !parser.isSet(QStringLiteral("appstream-metainfo")) && !parser.isSet(QStringLiteral("u")) && !parser.isSet(QStringLiteral("l"))
0062         && !parser.isSet(QStringLiteral("list-types")) && !parser.isSet(QStringLiteral("r")) && !parser.isSet(QStringLiteral("generate-index"))
0063         && !parser.isSet(QStringLiteral("remove-index"))) {
0064         parser.showHelp(0);
0065     }
0066     return app.exec();
0067 }