summaryrefslogtreecommitdiffstats
path: root/src/sdk
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/sdk
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/sdk')
-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
4 files changed, 54 insertions, 54 deletions
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();