diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-07-28 17:34:04 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-08-29 12:43:24 +0200 |
commit | e9e26f11d78def8ad8cb8f1864c61d88e3a1f0be (patch) | |
tree | cc7eb523e248e90c364767f511f5cdb02e1a3b07 /src/sdk/commandlineparser.cpp | |
parent | df2663a932ffc1e68fbde4b9c60efb93e36b519e (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/sdk/commandlineparser.cpp')
-rw-r--r-- | src/sdk/commandlineparser.cpp | 106 |
1 files changed, 106 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.")); +} |