KPackage

main.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Aaron Seigo <aseigo@kde.org>
3 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8/**
9 * kpackagetool6 exit codes used in this program
10
11 0 No error
12
13 1 Unspecified error
14 2 Plugin is not installed
15 3 Plugin or package invalid
16 4 Installation failed, see stderr for reason
17 5 Could not find a suitable installer for package type
18 6 No install option given
19 7 Conflicting arguments supplied
20 8 Uninstallation failed, see stderr for reason
21 9 Failed to generate package hash
22
23*/
24
25#include <KLocalizedString>
26#include <QCommandLineParser>
27
28#include "kpackagetool.h"
29#include "options.h"
30
31int main(int argc, char **argv)
32{
33 QCommandLineParser parser;
34 KPackage::PackageTool app(argc, argv, &parser);
35
36 const QString description = i18n("KPackage Manager");
37 const auto version = QStringLiteral("2.0");
38
39 app.setApplicationVersion(version);
40 parser.addVersionOption();
41 parser.addHelpOption();
42 parser.setApplicationDescription(description);
43 parser.addOptions({Options::hash(),
44 Options::global(),
45 Options::type(),
46 Options::install(),
47 Options::show(),
48 Options::upgrade(),
49 Options::list(),
50 Options::listTypes(),
51 Options::remove(),
52 Options::packageRoot(),
53 Options::appstream(),
54 Options::appstreamOutput()});
55 parser.process(app);
56
57 // at least one operation should be specified
58 if (!parser.isSet(QStringLiteral("hash")) && !parser.isSet(QStringLiteral("g")) && !parser.isSet(QStringLiteral("i")) && !parser.isSet(QStringLiteral("s"))
59 && !parser.isSet(QStringLiteral("appstream-metainfo")) && !parser.isSet(QStringLiteral("u")) && !parser.isSet(QStringLiteral("l"))
60 && !parser.isSet(QStringLiteral("list-types")) && !parser.isSet(QStringLiteral("r")) && !parser.isSet(QStringLiteral("generate-index"))
61 && !parser.isSet(QStringLiteral("remove-index"))) {
62 parser.showHelp(0);
63 }
64 return app.exec();
65}
QString i18n(const char *text, const TYPE &arg...)
KCOREADDONS_EXPORT unsigned int version()
QCommandLineOption addHelpOption()
bool addOptions(const QList< QCommandLineOption > &options)
QCommandLineOption addVersionOption()
bool isSet(const QCommandLineOption &option) const const
void process(const QCoreApplication &app)
void setApplicationDescription(const QString &description)
void showHelp(int exitCode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.