summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-03-13 16:16:52 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-03-19 12:31:46 +0200
commit559a6b4ed5b23fee084929f9f62fabe223294f49 (patch)
tree863a38c697a5e59805cb076a21aa95fa01c3a858 /src
parent8878f49cc00a5dcd0a8acd89cd5c9d8b89505941 (diff)
Add short versions of CLI options
Add single or couple letter short options and two letter short commands. Single letter short options can be passed in a single joined form, for instance '-dg'. Also change CLI options constant string literals type to QLatin1String as we would have to use this as a wrapper anyway wherever the constants would be used, causing quite long and verbose statements. Task-number: QTIFW-1634 Change-Id: I17e80c9a657d934687d2b7e87fcecddffa1b9b21 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/commandlineparser.cpp104
-rw-r--r--src/libs/installer/constants.h107
-rw-r--r--src/sdk/commandlineinterface.cpp4
-rw-r--r--src/sdk/installerbase.cpp10
-rw-r--r--src/sdk/main.cpp50
-rw-r--r--src/sdk/sdkapp.h44
6 files changed, 186 insertions, 133 deletions
diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp
index 0a5ce94de..c82dde944 100644
--- a/src/libs/installer/commandlineparser.cpp
+++ b/src/libs/installer/commandlineparser.cpp
@@ -33,9 +33,9 @@
namespace CommandLineOptions {
-const char Command[] = "Command";
-const char Arguments[] = "Args";
-const char InstallerValue[] = "InstallerValue";
+static const QLatin1String scCommand("Command");
+static const QLatin1String scArguments("Args");
+static const QLatin1String scInstallerValue("InstallerValue");
} // namespace CommandLineOptions
@@ -43,32 +43,33 @@ CommandLineParser::CommandLineParser()
: d(new CommandLineParserPrivate())
{
static const QString preformatted = QLatin1String("\nCommands:\n")
- + QString::fromLatin1("\t%1 - install default or selected packages - <pkg1 pkg2 pkg3...>\n")
- .arg(QLatin1String(CommandLineOptions::Install))
- + QString::fromLatin1("\t%1 - show available updates information on maintenance tool\n")
- .arg(QLatin1String(CommandLineOptions::CheckUpdates))
- + QString::fromLatin1("\t%1 - update all or selected packages - <pkg1 pkg2 pkg3...>\n")
- .arg(QLatin1String(CommandLineOptions::Update))
- + QString::fromLatin1("\t%1 - uninstall packages and their child components - <pkg1 pkg2 pkg3...>\n")
- .arg(QLatin1String(CommandLineOptions::Remove))
- + QString::fromLatin1("\t%1 - list currently installed packages\n")
- .arg(QLatin1String(CommandLineOptions::List))
- + QString::fromLatin1("\t%1 - search available packages - <regexp>")
- .arg(QLatin1String(CommandLineOptions::Search));
+ + QString::fromLatin1("\t%1, %2 - install default or selected packages - <pkg1 pkg2 pkg3...>\n")
+ .arg(CommandLineOptions::scInstallShort, CommandLineOptions::scInstallLong)
+ + QString::fromLatin1("\t%1, %2 - show available updates information on maintenance tool\n")
+ .arg(CommandLineOptions::scCheckUpdatesShort, CommandLineOptions::scCheckUpdatesLong)
+ + QString::fromLatin1("\t%1, %2 - update all or selected packages - <pkg1 pkg2 pkg3...>\n")
+ .arg(CommandLineOptions::scUpdateShort, CommandLineOptions::scUpdateLong)
+ + QString::fromLatin1("\t%1, %2 - uninstall packages and their child components - <pkg1 pkg2 pkg3...>\n")
+ .arg(CommandLineOptions::scRemoveShort, CommandLineOptions::scRemoveLong)
+ + QString::fromLatin1("\t%1, %2 - list currently installed packages\n")
+ .arg(CommandLineOptions::scListShort, CommandLineOptions::scListLong)
+ + QString::fromLatin1("\t%1, %2 - search available packages - <regexp>")
+ .arg(CommandLineOptions::scSearchShort, CommandLineOptions::scSearchLong);
m_parser.setApplicationDescription(preformatted);
// Help & version information
m_parser.addHelpOption();
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Version),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scVersionShort << CommandLineOptions::scVersionLong,
QLatin1String("Displays version information.")));
// Output related options
m_parser.addOption(QCommandLineOption(QStringList()
- << QLatin1String(CommandLineOptions::VerboseShort)
- << QLatin1String(CommandLineOptions::VerboseLong),
+ << CommandLineOptions::scVerboseShort << CommandLineOptions::scVerboseLong,
QLatin1String("Verbose mode. Prints out more information.")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::LoggingRules),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scLoggingRulesShort << CommandLineOptions::scLoggingRulesLong,
QLatin1String("Enables logging according to passed rules. Comma separated logging rules "
"have the following syntax: loggingCategory=true/false. Passing empty logging "
"rules enables all logging categories. The following rules enable a single "
@@ -77,71 +78,91 @@ CommandLineParser::CommandLineParser()
QLatin1String("rules")));
// Repository management options
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::AddRepository),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scAddRepositoryShort << CommandLineOptions::scAddRepositoryLong,
QLatin1String("Add a local or remote repository to the list of user defined repositories."),
QLatin1String("URI,...")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::AddTmpRepository),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scAddTmpRepositoryShort << CommandLineOptions::scAddTmpRepositoryLong,
QLatin1String("Add a local or remote repository to the list of temporary available repositories."),
QLatin1String("URI,...")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::SetTmpRepository),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scSetTmpRepositoryShort << CommandLineOptions::scSetTmpRepositoryLong,
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,...")));
// Proxy options
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::SystemProxy),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scSystemProxyShort << CommandLineOptions::scSystemProxyLong,
QLatin1String("Use system proxy on Windows and Linux. This option has no effect on macOS. (Default)")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::NoProxy),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scNoProxyShort << CommandLineOptions::scNoProxyLong,
QLatin1String("Do not use system proxy.")));
// Starting mode options
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::StartUpdater),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scStartUpdaterShort << CommandLineOptions::scStartUpdaterLong,
QLatin1String("Start application in updater mode. This will override the internal "
"marker that is used to distinguish which kind of binary is currently running.")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::StartPackageManager),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scStartPackageManagerShort << CommandLineOptions::scStartPackageManagerLong,
QLatin1String("Start application in package manager mode. This will override the internal "
"marker that is used to distinguish which kind of binary is currently running.")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::StartUninstaller),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scStartUninstallerShort << CommandLineOptions::scStartUninstallerLong,
QLatin1String("Start application in uninstaller mode. This will override the internal "
"marker that is used to distinguish which kind of binary is currently running.")));
// Misc installation options
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Root),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scRootShort << CommandLineOptions::scRootLong,
QLatin1String("Set installation root directory."),
QLatin1String("directory")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Platform),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scPlatformShort << CommandLineOptions::scPlatformLong,
QLatin1String("Use the specified platform plugin."),
QLatin1String("plugin")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::NoForceInstallation),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scNoForceInstallationShort << CommandLineOptions::scNoForceInstallationLong,
QLatin1String("Allow deselecting components that are marked as forced.")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::NoSizeChecking),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scNoSizeCheckingShort << CommandLineOptions::scNoSizeCheckingLong,
QLatin1String("Disable checking of free space for installation target.")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ShowVirtualComponents),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scShowVirtualComponentsShort << CommandLineOptions::scShowVirtualComponentsLong,
QLatin1String("Show virtual components in installer and package manager.")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::InstallCompressedRepository),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scInstallCompressedRepositoryShort
+ << CommandLineOptions::scInstallCompressedRepositoryLong,
QLatin1String("Installs QBSP or 7z file. The QBSP (Board Support Package) file must be a .7z "
"file which contains a valid repository."),
QLatin1String("URI,...")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::CreateLocalRepository),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scCreateLocalRepositoryShort << CommandLineOptions::scCreateLocalRepositoryLong,
QLatin1String("Create a local repository inside the installation directory. This option "
"has no effect on online installers.")));
// Developer options
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::Script),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scScriptShort << CommandLineOptions::scScriptLong,
QLatin1String("Execute the script given as argument."),
QLatin1String("file")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::StartServer),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scStartServerShort << CommandLineOptions::scStartServerLong,
QLatin1String("Starts the application as headless process waiting for commands to execute. Mode "
"can be DEBUG or PRODUCTION. In DEBUG mode, the option values can be omitted. Note: "
"The server will not shutdown on his own, you need to quit the process by hand."),
QLatin1String("mode, socketname, key")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::StartClient),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scStartClientShort << CommandLineOptions::scStartClientLong,
QLatin1String("Starts the application to debug the client-server communication. If a value is "
"omitted, the client will use a default instead. Note: The server process is not "
"started by the client application in that case, you need to start it on your own."),
QLatin1String("socketname, key")));
- m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::SquishPort),
+ m_parser.addOption(QCommandLineOption(QStringList()
+ << CommandLineOptions::scSquishPortShort << CommandLineOptions::scSquishPortLong,
QLatin1String("Give a port where Squish can connect to. If no port is given, default port 11233 is "
"used. Note: To enable Squish support you first need to build IFW with SQUISH_PATH "
"parameter where SQUISH_PATH is pointing to your Squish installation folder: "
@@ -152,16 +173,15 @@ CommandLineParser::CommandLineParser()
m_parser.addOptions(d->extensionsOptions());
// Positional arguments
- m_parser.addPositionalArgument(QLatin1String(CommandLineOptions::Command),
+ m_parser.addPositionalArgument(CommandLineOptions::scCommand,
QLatin1String("Command to be run by installer."),
QLatin1String("command"));
- m_parser.addPositionalArgument(QLatin1String(CommandLineOptions::Arguments),
+ m_parser.addPositionalArgument(CommandLineOptions::scArguments,
QLatin1String("Extra arguments for command, each separated by space."),
QLatin1String("<args>"));
- m_parser.addPositionalArgument(QLatin1String(CommandLineOptions::InstallerValue),
+ m_parser.addPositionalArgument(CommandLineOptions::scInstallerValue,
QLatin1String("Key-value pair to be set internally by the framework."),
QLatin1String("<key=value>"));
-
}
CommandLineParser::~CommandLineParser()
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 1dd36a9b0..37eb9600a 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -100,60 +100,93 @@ const char scRelocatable[] = "@RELOCATABLE_PATH@";
namespace CommandLineOptions {
// Help & version information
-const char HelpShort[] = "h";
-const char HelpLong[] = "help";
-const char Version[] = "version";
+static const QLatin1String scHelpShort("h");
+static const QLatin1String scHelpLong("help");
+static const QLatin1String scVersionShort("v");
+static const QLatin1String scVersionLong("version");
// Output related options
-const char VerboseShort[] = "v";
-const char VerboseLong[] = "verbose";
-const char LoggingRules[] = "logging-rules";
+static const QLatin1String scVerboseShort("d");
+static const QLatin1String scVerboseLong("verbose");
+static const QLatin1String scLoggingRulesShort("g");
+static const QLatin1String scLoggingRulesLong("logging-rules");
// Consumer commands
-const char Install[] = "install";
-const char CheckUpdates[] = "check-updates";
-const char Update[] = "update";
-const char Remove[] = "remove";
-const char List[] = "list";
-const char Search[] = "search";
+static const QLatin1String scInstallShort("in");
+static const QLatin1String scInstallLong("install");
+static const QLatin1String scCheckUpdatesShort("ch");
+static const QLatin1String scCheckUpdatesLong("check-updates");
+static const QLatin1String scUpdateShort("up");
+static const QLatin1String scUpdateLong("update");
+static const QLatin1String scRemoveShort("rm");
+static const QLatin1String scRemoveLong("remove");
+static const QLatin1String scListShort("li");
+static const QLatin1String scListLong("list");
+static const QLatin1String scSearchShort("se");
+static const QLatin1String scSearchLong("search");
// Repository management options
-const char AddRepository[] = "add-repository";
-const char AddTmpRepository[] = "add-temp-repository";
-const char SetTmpRepository[] = "set-temp-repository";
+static const QLatin1String scAddRepositoryShort("ar");
+static const QLatin1String scAddRepositoryLong("add-repository");
+static const QLatin1String scAddTmpRepositoryShort("at");
+static const QLatin1String scAddTmpRepositoryLong("add-temp-repository");
+static const QLatin1String scSetTmpRepositoryShort("st");
+static const QLatin1String scSetTmpRepositoryLong("set-temp-repository");
// Proxy options
-const char SystemProxy[] = "system-proxy";
-const char NoProxy[] = "no-proxy";
+static const QLatin1String scSystemProxyShort("sp");
+static const QLatin1String scSystemProxyLong("system-proxy");
+static const QLatin1String scNoProxyShort("np");
+static const QLatin1String scNoProxyLong("no-proxy");
// Starting mode options
-const char StartUpdater[] = "start-updater";
-const char StartPackageManager[] = "start-package-manager";
-const char StartUninstaller[] = "start-uninstaller";
+static const QLatin1String scStartUpdaterShort("su");
+static const QLatin1String scStartUpdaterLong("start-updater");
+static const QLatin1String scStartPackageManagerShort("sm");
+static const QLatin1String scStartPackageManagerLong("start-package-manager");
+static const QLatin1String scStartUninstallerShort("sr");
+static const QLatin1String scStartUninstallerLong("start-uninstaller");
// Misc installation options
-const char Root[] = "root";
-const char Platform[] = "platform";
-const char NoForceInstallation[] = "no-force-installations";
-const char NoSizeChecking[] = "no-size-checking";
-const char ShowVirtualComponents[] = "show-virtual-components";
-const char InstallCompressedRepository[] = "install-compressed-repository";
-const char CreateLocalRepository[] = "create-local-repository";
+static const QLatin1String scRootShort("t");
+static const QLatin1String scRootLong("root");
+static const QLatin1String scPlatformShort("p");
+static const QLatin1String scPlatformLong("platform");
+static const QLatin1String scNoForceInstallationShort("nf");
+static const QLatin1String scNoForceInstallationLong("no-force-installations");
+static const QLatin1String scNoSizeCheckingShort("ns");
+static const QLatin1String scNoSizeCheckingLong("no-size-checking");
+static const QLatin1String scShowVirtualComponentsShort("sv");
+static const QLatin1String scShowVirtualComponentsLong("show-virtual-components");
+static const QLatin1String scInstallCompressedRepositoryShort("i");
+static const QLatin1String scInstallCompressedRepositoryLong("install-compressed-repository");
+static const QLatin1String scCreateLocalRepositoryShort("c");
+static const QLatin1String scCreateLocalRepositoryLong("create-local-repository");
// Developer options
-const char Script[] = "script";
-const char StartServer[] = "start-server";
-const char StartClient[] = "start-client";
-const char SquishPort[] = "squish-port";
+static const QLatin1String scScriptShort("s");
+static const QLatin1String scScriptLong("script");
+static const QLatin1String scStartServerShort("ss");
+static const QLatin1String scStartServerLong("start-server");
+static const QLatin1String scStartClientShort("sc");
+static const QLatin1String scStartClientLong("start-client");
+static const QLatin1String scSquishPortShort("q");
+static const QLatin1String scSquishPortLong("squish-port");
// Options supposed to be used without graphical interface
static const QStringList scCommandLineInterfaceOptions = {
- QLatin1String(Install),
- QLatin1String(CheckUpdates),
- QLatin1String(Update),
- QLatin1String(Remove),
- QLatin1String(List),
- QLatin1String(Search)
+ scInstallShort,
+ scInstallLong,
+ scCheckUpdatesShort,
+ scCheckUpdatesLong,
+ scUpdateShort,
+ scUpdateLong,
+ scRemoveShort,
+ scRemoveLong,
+ scListShort,
+ scListLong,
+ scSearchShort,
+ scSearchLong
};
} // namespace CommandLineOptions
diff --git a/src/sdk/commandlineinterface.cpp b/src/sdk/commandlineinterface.cpp
index c5b829084..17e7be6e5 100644
--- a/src/sdk/commandlineinterface.cpp
+++ b/src/sdk/commandlineinterface.cpp
@@ -187,8 +187,8 @@ bool CommandLineInterface::checkLicense()
bool CommandLineInterface::setTargetDir()
{
QString targetDir;
- if (m_parser.isSet(QLatin1String(CommandLineOptions::Root))) {
- targetDir = m_parser.value(QLatin1String(CommandLineOptions::Root));
+ if (m_parser.isSet(CommandLineOptions::scRootLong)) {
+ targetDir = m_parser.value(CommandLineOptions::scRootLong);
} else {
targetDir = m_core->value(QLatin1String("TargetDir"));
qCDebug(QInstaller::lcInstallerInstallLog) << "No target directory specified, using default value:" << targetDir;
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 3cc5db5a5..8a3d18327 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -66,14 +66,14 @@ int InstallerBase::run()
return EXIT_FAILURE;
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::ShowVirtualComponents))) {
+ if (m_parser.isSet(CommandLineOptions::scShowVirtualComponentsLong)) {
QFont f;
f.setItalic(true);
QInstaller::PackageManagerCore::setVirtualComponentsFont(f);
}
QString controlScript;
- if (m_parser.isSet(QLatin1String(CommandLineOptions::Script))) {
- controlScript = m_parser.value(QLatin1String(CommandLineOptions::Script));
+ if (m_parser.isSet(CommandLineOptions::scScriptLong)) {
+ controlScript = m_parser.value(CommandLineOptions::scScriptLong);
if (!QFileInfo(controlScript).exists()) {
qCDebug(QInstaller::lcInstallerInstallLog) << "Script file does not exist.";
return false;
@@ -144,8 +144,8 @@ int InstallerBase::run()
#ifdef ENABLE_SQUISH
int squishPort = 11233;
- if (m_parser.isSet(QLatin1String(CommandLineOptions::SquishPort))) {
- squishPort = m_parser.value(QLatin1String(CommandLineOptions::SquishPort)).toInt();
+ if (m_parser.isSet(CommandLineOptions::scSquishPortLong)) {
+ squishPort = m_parser.value(CommandLineOptions::scSquishPortLong).toInt();
}
if (squishPort != 0) {
if (Squish::allowAttaching(squishPort))
diff --git a/src/sdk/main.cpp b/src/sdk/main.cpp
index 19462fdf5..d76b97d83 100644
--- a/src/sdk/main.cpp
+++ b/src/sdk/main.cpp
@@ -86,12 +86,12 @@ int main(int argc, char *argv[])
QString sanityMessage;
QStringList mutually;
- if (parser.isSet(QLatin1String(CommandLineOptions::StartUpdater)))
- mutually << QLatin1String(CommandLineOptions::StartUpdater);
- if (parser.isSet(QLatin1String(CommandLineOptions::StartPackageManager)))
- mutually << QLatin1String(CommandLineOptions::StartPackageManager);
- if (parser.isSet(QLatin1String(CommandLineOptions::StartUninstaller)))
- mutually << QLatin1String(CommandLineOptions::StartUninstaller);
+ if (parser.isSet(CommandLineOptions::scStartUpdaterLong))
+ mutually << CommandLineOptions::scStartUpdaterLong;
+ if (parser.isSet(CommandLineOptions::scStartPackageManagerLong))
+ mutually << CommandLineOptions::scStartPackageManagerLong;
+ if (parser.isSet(CommandLineOptions::scStartUninstallerLong))
+ mutually << CommandLineOptions::scStartUninstallerLong;
if (mutually.count() > 1) {
sanityMessage = QString::fromLatin1("The following options are mutually exclusive: %1.")
@@ -110,13 +110,12 @@ int main(int argc, char *argv[])
"argument. \"%1\" given.").arg(parser.positionalArguments().first());
sanityCheck = false;
}
- const bool help = parser.isSet(QLatin1String(CommandLineOptions::HelpShort))
- || parser.isSet(QLatin1String(CommandLineOptions::HelpLong));
- if (help || parser.isSet(QLatin1String(CommandLineOptions::Version)) || !sanityCheck) {
+ const bool help = parser.isSet(CommandLineOptions::scHelpLong);
+ if (help || parser.isSet(CommandLineOptions::scVersionLong) || !sanityCheck) {
Console c;
QCoreApplication app(argc, argv);
- if (parser.isSet(QLatin1String(CommandLineOptions::Version))) {
+ if (parser.isSet(CommandLineOptions::scVersionLong)) {
std::cout << VERSION << std::endl << BUILDDATE << std::endl << SHA << std::endl;
const QDateTime dateTime = QDateTime::fromString(QLatin1String(PLACEHOLDER),
QLatin1String("yyyy-MM-dd - HH:mm:ss"));
@@ -132,8 +131,8 @@ int main(int argc, char *argv[])
return help ? EXIT_SUCCESS : EXIT_FAILURE;
}
- if (parser.isSet(QLatin1String(CommandLineOptions::StartServer))) {
- const QStringList arguments = parser.value(QLatin1String(CommandLineOptions::StartServer))
+ if (parser.isSet(CommandLineOptions::scStartServerLong)) {
+ const QStringList arguments = parser.value(CommandLineOptions::scStartServerLong)
.split(QLatin1Char(','), QString::SkipEmptyParts);
QString socketName, key;
@@ -198,8 +197,7 @@ int main(int argc, char *argv[])
QScopedPointer<Console> console;
// Check if any options requiring verbose output is set
- bool setVerbose = parser.isSet(QLatin1String(CommandLineOptions::VerboseShort))
- || parser.isSet(QLatin1String(CommandLineOptions::VerboseLong));
+ bool setVerbose = parser.isSet(CommandLineOptions::scVerboseLong);
foreach (const QString &option, CommandLineOptions::scCommandLineInterfaceOptions) {
if (setVerbose) break;
@@ -217,29 +215,35 @@ int main(int argc, char *argv[])
std::cerr << "Unknown option: " << qPrintable(options) << std::endl;
}
- if (parser.isSet(QLatin1String(CommandLineOptions::SystemProxy))) {
+ if (parser.isSet(CommandLineOptions::scSystemProxyLong)) {
// Make sure we honor the system's proxy settings
QNetworkProxyFactory::setUseSystemConfiguration(true);
}
- if (parser.isSet(QLatin1String(CommandLineOptions::NoProxy)))
+ if (parser.isSet(CommandLineOptions::scNoProxyLong))
QNetworkProxyFactory::setUseSystemConfiguration(false);
const SelfRestarter restarter(argc, argv);
- if (parser.positionalArguments().contains(QLatin1String(CommandLineOptions::CheckUpdates)))
+ if (parser.positionalArguments().contains(CommandLineOptions::scCheckUpdatesShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scCheckUpdatesLong)) {
return CommandLineInterface(argc, argv).checkUpdates();
- if (parser.positionalArguments().contains(QLatin1String(CommandLineOptions::List)))
+ } else if (parser.positionalArguments().contains(CommandLineOptions::scListShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scListLong)) {
return CommandLineInterface(argc, argv).listInstalledPackages();
- if (parser.positionalArguments().contains(QLatin1String(CommandLineOptions::Search)))
+ } else if (parser.positionalArguments().contains(CommandLineOptions::scSearchShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scSearchLong)) {
return CommandLineInterface(argc, argv).searchAvailablePackages();
- if (parser.positionalArguments().contains(QLatin1String(CommandLineOptions::Update)))
+ } else if (parser.positionalArguments().contains(CommandLineOptions::scUpdateShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scUpdateLong)) {
return CommandLineInterface(argc, argv).updatePackages();
- if (parser.positionalArguments().contains(QLatin1String(CommandLineOptions::Install)))
+ } else if (parser.positionalArguments().contains(CommandLineOptions::scInstallShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scInstallLong)) {
return CommandLineInterface(argc, argv).installPackages();
- if (parser.positionalArguments().contains(QLatin1String(CommandLineOptions::Remove)))
+ } else if (parser.positionalArguments().contains(CommandLineOptions::scRemoveShort)
+ || parser.positionalArguments().contains(CommandLineOptions::scRemoveLong)){
return CommandLineInterface(argc, argv).uninstallPackages();
-
+ }
if (QInstaller::isVerbose())
std::cout << VERSION << std::endl << BUILDDATE << std::endl << SHA << std::endl;
diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h
index ca52430d2..d7905f1f0 100644
--- a/src/sdk/sdkapp.h
+++ b/src/sdk/sdkapp.h
@@ -140,8 +140,8 @@ public:
}
}
if (QInstaller::isVerbose()) {
- if (m_parser.isSet(QLatin1String(CommandLineOptions::LoggingRules))) {
- loggingRules = m_parser.value(QLatin1String(CommandLineOptions::LoggingRules))
+ if (m_parser.isSet(CommandLineOptions::scLoggingRulesLong)) {
+ loggingRules = m_parser.value(CommandLineOptions::scLoggingRulesLong)
.split(QLatin1Char(','), QString::SkipEmptyParts)
.join(QLatin1Char('\n')); // take rules from command line
} else if (isCliInterface) {
@@ -163,8 +163,8 @@ public:
QLoggingCategory::setFilterRules(loggingRules);
SDKApp::registerMetaResources(manager.collectionByName("QResources"));
- if (m_parser.isSet(QLatin1String(CommandLineOptions::StartClient))) {
- const QStringList arguments = m_parser.value(QLatin1String(CommandLineOptions::StartClient))
+ if (m_parser.isSet(CommandLineOptions::scStartClientLong)) {
+ const QStringList arguments = m_parser.value(CommandLineOptions::scStartClientLong)
.split(QLatin1Char(','), QString::SkipEmptyParts);
m_core = new QInstaller::PackageManagerCore(
magicMarker, oldOperations,
@@ -186,7 +186,7 @@ public:
// From Qt5.8 onwards system proxy is used by default. If Qt is built with
// QT_USE_SYSTEM_PROXIES false then system proxies are not used by default.
- if (m_parser.isSet(QLatin1String(CommandLineOptions::NoProxy))) {
+ if (m_parser.isSet(CommandLineOptions::scNoProxyLong)) {
m_core->settings().setProxyType(QInstaller::Settings::NoProxy);
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
} else if (QNetworkProxyFactory::usesSystemConfiguration()) {
@@ -194,10 +194,10 @@ public:
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::ShowVirtualComponents)))
+ if (m_parser.isSet(CommandLineOptions::scShowVirtualComponentsLong))
QInstaller::PackageManagerCore::setVirtualComponentsVisible(true);
- if (m_parser.isSet(QLatin1String(CommandLineOptions::StartUpdater))) {
+ if (m_parser.isSet(CommandLineOptions::scStartUpdaterLong)) {
if (m_core->isInstaller()) {
errorMessage = QObject::tr("Cannot start installer binary as updater.");
return false;
@@ -205,7 +205,7 @@ public:
m_core->setUserSetBinaryMarker(QInstaller::BinaryContent::MagicUpdaterMarker);
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::StartPackageManager))) {
+ if (m_parser.isSet(CommandLineOptions::scStartPackageManagerLong)) {
if (m_core->isInstaller()) {
errorMessage = QObject::tr("Cannot start installer binary as package manager.");
return false;
@@ -213,7 +213,7 @@ public:
m_core->setUserSetBinaryMarker(QInstaller::BinaryContent::MagicPackageManagerMarker);
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::StartUninstaller))) {
+ if (m_parser.isSet(CommandLineOptions::scStartUninstallerLong)) {
if (m_core->isInstaller()) {
errorMessage = QObject::tr("Cannot start installer binary as uninstaller.");
return false;
@@ -221,9 +221,8 @@ public:
m_core->setUserSetBinaryMarker(QInstaller::BinaryContent::MagicUninstallerMarker);
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::AddRepository))) {
- const QStringList repoList = repositories(m_parser
- .value(QLatin1String(CommandLineOptions::AddRepository)));
+ if (m_parser.isSet(CommandLineOptions::scAddRepositoryLong)) {
+ const QStringList repoList = repositories(m_parser.value(CommandLineOptions::scAddRepositoryLong));
if (repoList.isEmpty()) {
errorMessage = QObject::tr("Empty repository list for option 'addRepository'.");
return false;
@@ -231,9 +230,8 @@ public:
m_core->addUserRepositories(repoList);
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::AddTmpRepository))) {
- const QStringList repoList = repositories(m_parser
- .value(QLatin1String(CommandLineOptions::AddTmpRepository)));
+ if (m_parser.isSet(CommandLineOptions::scAddTmpRepositoryLong)) {
+ const QStringList repoList = repositories(m_parser.value(CommandLineOptions::scAddTmpRepositoryLong));
if (repoList.isEmpty()) {
errorMessage = QObject::tr("Empty repository list for option 'addTempRepository'.");
return false;
@@ -241,9 +239,8 @@ public:
m_core->setTemporaryRepositories(repoList, false);
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::SetTmpRepository))) {
- const QStringList repoList = repositories(m_parser
- .value(QLatin1String(CommandLineOptions::SetTmpRepository)));
+ if (m_parser.isSet(CommandLineOptions::scSetTmpRepositoryLong)) {
+ const QStringList repoList = repositories(m_parser.value(CommandLineOptions::scSetTmpRepositoryLong));
if (repoList.isEmpty()) {
errorMessage = QObject::tr("Empty repository list for option 'setTempRepository'.");
return false;
@@ -251,9 +248,8 @@ public:
m_core->setTemporaryRepositories(repoList, true);
}
- if (m_parser.isSet(QLatin1String(CommandLineOptions::InstallCompressedRepository))) {
- const QStringList repoList = repositories(m_parser
- .value(QLatin1String(CommandLineOptions::InstallCompressedRepository)));
+ if (m_parser.isSet(CommandLineOptions::scInstallCompressedRepositoryLong)) {
+ const QStringList repoList = repositories(m_parser.value(CommandLineOptions::scInstallCompressedRepositoryLong));
if (repoList.isEmpty()) {
errorMessage = QObject::tr("Empty repository list for option 'installCompressedRepository'.");
return false;
@@ -267,13 +263,13 @@ public:
m_core->setTemporaryRepositories(repoList, false, true);
}
// Disable checking for free space on target
- if (m_parser.isSet(QLatin1String(CommandLineOptions::NoSizeChecking)))
+ if (m_parser.isSet(CommandLineOptions::scNoSizeCheckingLong))
m_core->setCheckAvailableSpace(false);
QInstaller::PackageManagerCore::setNoForceInstallation(m_parser
- .isSet(QLatin1String(CommandLineOptions::NoForceInstallation)));
+ .isSet(CommandLineOptions::scNoForceInstallationLong));
QInstaller::PackageManagerCore::setCreateLocalRepositoryFromBinary(m_parser
- .isSet(QLatin1String(CommandLineOptions::CreateLocalRepository))
+ .isSet(CommandLineOptions::scCreateLocalRepositoryLong)
|| m_core->settings().createLocalRepository());
const QStringList positionalArguments = m_parser.positionalArguments();