summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-07-28 17:34:04 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-08-29 12:43:24 +0200
commite9e26f11d78def8ad8cb8f1864c61d88e3a1f0be (patch)
treecc7eb523e248e90c364767f511f5cdb02e1a3b07 /src
parentdf2663a932ffc1e68fbde4b9c60efb93e36b519e (diff)
Introduce commandline parser class.
Though it just wraps the Qt class, it does at least some useful setup in its constructor, will reuse that in the next commit. Change-Id: I7b876d196540baad197bdbf85babbeaea62f8c27 Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/sdk/commandlineparser.cpp106
-rw-r--r--src/sdk/commandlineparser.h63
-rw-r--r--src/sdk/constants.h67
3 files changed, 236 insertions, 0 deletions
diff --git a/src/sdk/commandlineparser.cpp b/src/sdk/commandlineparser.cpp
new file mode 100644
index 000000000..eb8ae678d
--- /dev/null
+++ b/src/sdk/commandlineparser.cpp
@@ -0,0 +1,106 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#include "commandlineparser.h"
+
+#include "constants.h"
+
+namespace CommandLineOptions {
+const char KeyValue[] = "Key=Value";
+} // namespace CommandLineOptions
+
+CommandLineParser::CommandLineParser()
+{
+ m_parser.addHelpOption();
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Version),
+ QLatin1String("Displays version information.")));
+
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << QLatin1String(CommandLineOptions::VerboseShort)
+ << QLatin1String(CommandLineOptions::VerboseLong),
+ QLatin1String("Verbose mode. Prints out more information.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Proxy),
+ QLatin1String("Use system proxy on Windows and OS X. This option has no effect on Linux.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Script),
+ QLatin1String("Execute the script given as argument."), QLatin1String("file")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::CheckUpdates),
+ QLatin1String("Check for updates and return an XML description.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Updater),
+ QLatin1String("Start application in updater mode.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ManagePackages),
+ QLatin1String("Start application in package manager mode.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::NoForceInstallation),
+ QLatin1String("Allow deselection of components that are marked as forced.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ShowVirtualComponents),
+ QLatin1String("Show virtual components in installer and package manager.")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::CreateOfflineRepository),
+ QLatin1String("Create a local repository inside the installation directory. This option "
+ "has no effect on online installer's")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::AddRepository),
+ QLatin1String("Add a local or remote repository to the list of user defined repositories."),
+ QLatin1String("URI,...")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::AddTmpRepository),
+ QLatin1String("Add a local or remote repository to the list of temporary available "
+ "repositories."), QLatin1String("URI,...")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::SetTmpRepository),
+ QLatin1String("Set a local or remote repository as temporary repository, it is the only "
+ "one used during fetch.\nNote: URI must be prefixed with the protocol, i.e. file:///, "
+ "https://, http:// or ftp://."), QLatin1String("URI,...")));
+
+ m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::StartServer),
+ QLatin1String("Starts the application as headless process waiting for commands to execute."),
+ QLatin1String("port,key")));
+
+ m_parser.addPositionalArgument(QLatin1String(CommandLineOptions::KeyValue),
+ QLatin1String("Key Value pair to be set."));
+}
diff --git a/src/sdk/commandlineparser.h b/src/sdk/commandlineparser.h
new file mode 100644
index 000000000..87bc6dfc6
--- /dev/null
+++ b/src/sdk/commandlineparser.h
@@ -0,0 +1,63 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#ifndef COMMANDLINEPARSER_H
+#define COMMANDLINEPARSER_H
+
+#include <QCommandLineParser>
+
+class CommandLineParser
+{
+public:
+ CommandLineParser();
+
+ QString helpText() const { return m_parser.helpText(); }
+ bool isSet(const QString &option) { return m_parser.isSet(option); }
+ QStringList unknownOptionNames() const { return m_parser.unknownOptionNames(); }
+ QStringList positionalArguments() const { return m_parser.positionalArguments(); }
+ bool parse(const QStringList &argumens) { return m_parser.parse(argumens); }
+ QString value(const QString &option) const { return m_parser.value(option); }
+
+private:
+ QCommandLineParser m_parser;
+};
+
+#endif // COMMANDLINEPARSER_H
diff --git a/src/sdk/constants.h b/src/sdk/constants.h
new file mode 100644
index 000000000..770f0f4bf
--- /dev/null
+++ b/src/sdk/constants.h
@@ -0,0 +1,67 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#ifndef CONSTANTS_H
+#define CONSTANTS_H
+
+namespace CommandLineOptions {
+
+const char HelpShort[] = "h";
+const char HelpLong[] = "help";
+const char Version[] = "version";
+const char VerboseShort[] = "v";
+const char VerboseLong[] = "verbose";
+const char Proxy[] = "proxy";
+const char Script[] = "script";
+const char CheckUpdates[] = "checkupdates";
+const char Updater[] = "updater";
+const char ManagePackages[] = "manage-packages";
+const char NoForceInstallation[] = "no-force-installations";
+const char ShowVirtualComponents[] = "show-virtual-components";
+const char CreateOfflineRepository[] = "create-offline-repository";
+const char AddRepository[] = "addRepository";
+const char AddTmpRepository[] = "addTempRepository";
+const char SetTmpRepository[] = "setTempRepository";
+const char StartServer[] = "startserver";
+
+} // namespace CommandLineOptions
+
+#endif // CONSTANTS_H