diff options
Diffstat (limited to 'src/libs/installer/commandlineparser.cpp')
-rw-r--r-- | src/libs/installer/commandlineparser.cpp | 80 |
1 files changed, 72 insertions, 8 deletions
diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp index a04891303..f9e1f663e 100644 --- a/src/libs/installer/commandlineparser.cpp +++ b/src/libs/installer/commandlineparser.cpp @@ -48,7 +48,7 @@ CommandLineParser::CommandLineParser() "headless mode. The installation operations can be invoked with the following commands and " "options. Note that the options marked with \"CLI\" are available in the headless mode only.\n") + QLatin1String("\nCommands:\n") - + indent + QString::fromLatin1("%1, %2 - install default or selected packages - <pkg ...>\n") + + indent + QString::fromLatin1("%1, %2 - install default or selected packages and aliases - <pkg|alias ...>\n") .arg(CommandLineOptions::scInstallShort, CommandLineOptions::scInstallLong) + indent + QString::fromLatin1("%1, %2 - show available updates information on maintenance tool\n") .arg(CommandLineOptions::scCheckUpdatesShort, CommandLineOptions::scCheckUpdatesLong) @@ -56,15 +56,20 @@ CommandLineParser::CommandLineParser() .arg(CommandLineOptions::scUpdateShort, CommandLineOptions::scUpdateLong) + indent + QString::fromLatin1("%1, %2 - uninstall packages and their child components - <pkg ...>\n") .arg(CommandLineOptions::scRemoveShort, CommandLineOptions::scRemoveLong) - + indent + QString::fromLatin1("%1, %2 - list currently installed packages - <regexp>\n") + + indent + QString::fromLatin1("%1, %2 - list currently installed packages - <regexp for pkg>\n") .arg(CommandLineOptions::scListShort, CommandLineOptions::scListLong) - + indent + QString::fromLatin1("%1, %2 - search available packages - <regexp>\n") + + indent + QString::fromLatin1("%1, %2 - search available aliases or packages - <regexp for pkg|alias>\n") .arg(CommandLineOptions::scSearchShort, CommandLineOptions::scSearchLong) + indent + indent + QString::fromLatin1("Note: The --%1 option can be used to specify\n") .arg(CommandLineOptions::scFilterPackagesLong) + indent + indent + QLatin1String("additional filters for the search operation\n") + + indent + indent + QString::fromLatin1("Note: The --%1 option can be used to specify\n") + .arg(CommandLineOptions::scTypeLong) + + indent + indent + QLatin1String("the content type to search\n") + indent + QString::fromLatin1("%1, %2 - create offline installer from selected packages - <pkg ...>\n") .arg(CommandLineOptions::scCreateOfflineShort, CommandLineOptions::scCreateOfflineLong) + + indent + QString::fromLatin1("%1, %2 - clear contents of the local metadata cache\n") + .arg(CommandLineOptions::scClearCacheShort, CommandLineOptions::scClearCacheLong) + indent + QString::fromLatin1("%1, %2 - uninstall all packages and remove entire program directory") .arg(CommandLineOptions::scPurgeShort, CommandLineOptions::scPurgeLong); @@ -171,6 +176,16 @@ CommandLineParser::CommandLineParser() "search command. The keys can be any of the possible package information elements, like " "\"DisplayName\" and \"Description\"."), QLatin1String("element=regex,...")), CommandLineOnly); + addOption(QCommandLineOption(QStringList() + << CommandLineOptions::scLocalCachePathShort << CommandLineOptions::scLocalCachePathLong, + QLatin1String("Sets the path used for local metadata cache. The path must be writable by the current user."), + QLatin1String("path"))); + addOption(QCommandLineOption(QStringList() + << CommandLineOptions::scTypeLong, + QLatin1String("[CLI] Sets the type of the given arguments for commands supporting multiple argument types, " + "like \"search\". By default aliases are searched first, and if no matching aliases are found, " + "then packages are searched with the same search pattern."), + QLatin1String("package|alias"))); // Message query options addOptionWithContext(QCommandLineOption(QStringList() << CommandLineOptions::scAcceptMessageQueryShort @@ -195,7 +210,7 @@ CommandLineParser::CommandLineParser() QLatin1String("[CLI] Automatically sets the QFileDialog values getExistingDirectory() or getOpenFileName() " "requested by install script. " "Several identifier=value pairs can be given separated with comma, " - "for example --file-query filedialog.id=C:\Temp,filedialog.id2=C:\Temp2"), + "for example --file-query filedialog.id=C:/Temp,filedialog.id2=C:/Temp2"), QLatin1String("identifier=value")), CommandLineOnly); addOptionWithContext(QCommandLineOption(QStringList() << CommandLineOptions::scConfirmCommandShort << CommandLineOptions::scConfirmCommandLong, QLatin1String("[CLI] Confirms starting of " @@ -220,8 +235,8 @@ CommandLineParser::CommandLineParser() QLatin1String("socketname, key"))); 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 " + QLatin1String("Give a port where Squish can connect to. If no port is given, attach to squish " + "not done. 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: " "<path_to_qt>/bin/qmake -r SQUISH_PATH=<pat_to_squish>"), QLatin1String("port number"))); @@ -233,13 +248,23 @@ CommandLineParser::CommandLineParser() "processor cores in the system."), QLatin1String("threads"))); + QCommandLineOption cleanupUpdate(CommandLineOptions::scCleanupUpdate); + cleanupUpdate.setValueName(QLatin1String("path")); + cleanupUpdate.setFlags(QCommandLineOption::HiddenFromHelp); + addOption(cleanupUpdate); + + QCommandLineOption cleanupUpdateOnly(CommandLineOptions::scCleanupUpdateOnly); + cleanupUpdateOnly.setValueName(QLatin1String("path")); + cleanupUpdateOnly.setFlags(QCommandLineOption::HiddenFromHelp); + addOption(cleanupUpdateOnly); + // Deprecated options QCommandLineOption deprecatedUpdater(CommandLineOptions::scDeprecatedUpdater); - deprecatedUpdater.setHidden(true); + deprecatedUpdater.setFlags(QCommandLineOption::HiddenFromHelp); addOption(deprecatedUpdater); QCommandLineOption deprecatedCheckUpdates(CommandLineOptions::scDeprecatedCheckUpdates); - deprecatedCheckUpdates.setHidden(true); + deprecatedCheckUpdates.setFlags(QCommandLineOption::HiddenFromHelp); addOption(deprecatedCheckUpdates); // Behaves like check-updates but does not default to verbose output // Custom extension options @@ -277,3 +302,42 @@ CommandLineParser::OptionContextFlags CommandLineParser::optionContextFlags(cons { return m_optionContextFlagsNameHash.value(option); } + +/* + Returns the command line arguments of the application. The returned list + is context-aware, i.e. options that are set on the parser with + \c OptionContextFlag::NoEchoValue are returned with their value hidden. +*/ +QStringList CommandLineParser::arguments() const +{ + const QStringList arguments = QCoreApplication::arguments(); + QStringList returnArguments; + bool skipNext = false; + for (const QString &arg : arguments) { + if (skipNext) { + skipNext = false; + continue; + } + returnArguments << arg; + // Append positional arguments as-is + if (!arg.startsWith(QLatin1String("--")) && !arg.startsWith(QLatin1Char('-'))) + continue; + + QString normalizedOption = arg; + while (normalizedOption.startsWith(QLatin1Char('-'))) + normalizedOption.remove(QLatin1Char('-')); + + const OptionContextFlags flags = optionContextFlags(normalizedOption); + if (!flags.testFlag(OptionContextFlag::NoEchoValue)) + continue; + + QString nextArg = arguments.value(arguments.indexOf(arg) + 1); + if (!nextArg.isEmpty() && !nextArg.startsWith(QLatin1String("--")) + && !nextArg.startsWith(QLatin1Char('-'))) { + nextArg = QLatin1String("******"); + returnArguments << nextArg; + skipNext = true; + } + } + return returnArguments; +} |