diff options
author | Jarek Kobus <[email protected]> | 2024-05-16 14:07:59 +0200 |
---|---|---|
committer | Jarek Kobus <[email protected]> | 2024-05-22 09:13:41 +0000 |
commit | 982ad2424352f07877fb0a0af63df3790ebe165d (patch) | |
tree | d6114a48b392e4399526aea78e0fb9637a244662 /src/plugins | |
parent | d857af4cec9d1e3651f6c4759066ae953cd730c0 (diff) |
CommandLine: Reuse new c'tor
Change-Id: Id154881b4f5d8c488e5c1f5e0f843d36bf838759
Reviewed-by: Orgad Shaneh <[email protected]>
Reviewed-by: <[email protected]>
Diffstat (limited to 'src/plugins')
39 files changed, 104 insertions, 165 deletions
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index f9835e17b04..f5d4036a4fc 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -675,11 +675,9 @@ bool AndroidConfig::isConnected(const QString &serialNumber) const QString AndroidConfig::getDeviceProperty(const QString &device, const QString &property) { // workaround for '????????????' serial numbers - CommandLine cmd(androidConfig().adbToolPath(), AndroidDeviceInfo::adbSelector(device)); - cmd.addArgs({"shell", "getprop", property}); - Process adbProc; - adbProc.setCommand(cmd); + adbProc.setCommand({androidConfig().adbToolPath(), + {AndroidDeviceInfo::adbSelector(device), "shell", "getprop", property}}); adbProc.runBlocking(); if (adbProc.result() != ProcessResult::FinishedWithSuccess) return {}; @@ -752,10 +750,9 @@ QStringList AndroidConfig::getAbis(const QString &device) const FilePath adbTool = androidConfig().adbToolPath(); QStringList result; // First try via ro.product.cpu.abilist - QStringList arguments = AndroidDeviceInfo::adbSelector(device); - arguments << "shell" << "getprop" << "ro.product.cpu.abilist"; Process adbProc; - adbProc.setCommand({adbTool, arguments}); + adbProc.setCommand({adbTool, + {AndroidDeviceInfo::adbSelector(device), "shell", "getprop", "ro.product.cpu.abilist"}}); adbProc.runBlocking(); if (adbProc.result() != ProcessResult::FinishedWithSuccess) return result; @@ -769,15 +766,13 @@ QStringList AndroidConfig::getAbis(const QString &device) // Fall back to ro.product.cpu.abi, ro.product.cpu.abi2 ... for (int i = 1; i < 6; ++i) { - QStringList arguments = AndroidDeviceInfo::adbSelector(device); - arguments << QLatin1String("shell") << QLatin1String("getprop"); + CommandLine cmd{adbTool, {AndroidDeviceInfo::adbSelector(device), "shell", "getprop"}}; if (i == 1) - arguments << QLatin1String("ro.product.cpu.abi"); + cmd.addArg("ro.product.cpu.abi"); else - arguments << QString::fromLatin1("ro.product.cpu.abi%1").arg(i); - + cmd.addArg(QString::fromLatin1("ro.product.cpu.abi%1").arg(i)); Process abiProc; - abiProc.setCommand({adbTool, arguments}); + abiProc.setCommand(cmd); abiProc.runBlocking(); if (abiProc.result() != ProcessResult::FinishedWithSuccess) return result; diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index 459bdb6eead..539d65c6202 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -169,7 +169,7 @@ bool AndroidDeployQtStep::init() return false; } - m_androiddeployqtArgs = CommandLine(); + m_androiddeployqtArgs = {}; m_androidABIs = AndroidManager::applicationAbis(target()); if (m_androidABIs.isEmpty()) { @@ -371,8 +371,7 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy(QPromise<voi qCDebug(deployStepLog) << msg; emit addOutput(msg, OutputFormat::NormalMessage); runCommand({m_adbPath, - AndroidDeviceInfo::adbSelector(m_serialNumber) - << "uninstall" << packageName}); + {AndroidDeviceInfo::adbSelector(m_serialNumber), "uninstall", packageName}}); } cmd.addArgs(AndroidDeviceInfo::adbSelector(m_serialNumber)); @@ -519,9 +518,8 @@ void AndroidDeployQtStep::runImpl(QPromise<void> &promise) reportWarningOrError(error, Task::Error); } - runCommand({m_adbPath, - AndroidDeviceInfo::adbSelector(m_serialNumber) - << "pull" << itr.key() << itr.value().nativePath()}); + runCommand({m_adbPath, {AndroidDeviceInfo::adbSelector(m_serialNumber), "pull", itr.key(), + itr.value().nativePath()}}); if (!itr.value().exists()) { const QString error = Tr::tr("Package deploy: Failed to pull \"%1\" to \"%2\".") .arg(itr.key()) diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp index 997c0ced0af..2326a3b1058 100644 --- a/src/plugins/android/androiddevice.cpp +++ b/src/plugins/android/androiddevice.cpp @@ -690,7 +690,7 @@ void AndroidDeviceManager::setupDevicesWatcher() HandleDevicesListChange(output); }); - const CommandLine command = CommandLine(androidConfig().adbToolPath(), {"track-devices"}); + const CommandLine command{androidConfig().adbToolPath(), {"track-devices"}}; m_adbDeviceWatcherProcess->setCommand(command); m_adbDeviceWatcherProcess->setWorkingDirectory(command.executable().parentDir()); m_adbDeviceWatcherProcess->setEnvironment(androidConfig().toolsEnvironment()); diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp index a2631f0c536..ec3df9b33cc 100644 --- a/src/plugins/android/androidmanager.cpp +++ b/src/plugins/android/androidmanager.cpp @@ -639,8 +639,8 @@ bool checkCertificateExists(const FilePath &keystorePath, const QString &keystor const QString &alias) { // assumes that the keystore password is correct - QStringList arguments = { "-list", "-keystore", keystorePath.toUserOutput(), - "--storepass", keystorePasswd, "-alias", alias }; + const QStringList arguments = {"-list", "-keystore", keystorePath.toUserOutput(), + "--storepass", keystorePasswd, "-alias", alias}; Process proc; proc.setCommand({androidConfig().keytoolPath(), arguments}); diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 785d0c5ac90..de44a3f1cf5 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -733,7 +733,8 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent) const QString openSslRepo("https://github.com/KDAB/android_openssl.git"); Process *gitCloner = new Process(this); - CommandLine gitCloneCommand("git", {"clone", "--depth=1", openSslRepo, openSslPath.toString()}); + const CommandLine gitCloneCommand("git", {"clone", "--depth=1", openSslRepo, + openSslPath.toString()}); gitCloner->setCommand(gitCloneCommand); qCDebug(androidsettingswidget) << "Cloning OpenSSL repo: " << gitCloneCommand.toUserOutput(); diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index a9f68d6895a..2216a64cb20 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -93,7 +93,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi << QString::number(testSettings().timeout() / 1000); } options << theCTestTool().activeSettingsAsOptions(); - CommandLine command = buildSystem->commandLineForTests(selected, options); + const CommandLine command = buildSystem->commandLineForTests(selected, options); if (command.executable().isEmpty()) return {}; diff --git a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp index ed84508322c..3709736d842 100644 --- a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp @@ -210,10 +210,8 @@ ProjectExplorer::RunWorker *UvscServerProvider::targetRunner(RunControl *runCont { // Get uVision executable path. const ProcessRunData uv = DebuggerKitAspect::runnable(runControl->kit()); - CommandLine server(uv.command.executable()); - server.addArg("-j0"); - server.addArg(QStringLiteral("-s%1").arg(m_channel.port())); - + const CommandLine server{uv.command.executable(), + {"-j0", QStringLiteral("-s%1").arg(m_channel.port())}}; ProcessRunData r; r.command = server; return new UvscServerProviderRunner(runControl, r); diff --git a/src/plugins/baremetal/keiltoolchain.cpp b/src/plugins/baremetal/keiltoolchain.cpp index 0ca7495c94c..bc260130b2b 100644 --- a/src/plugins/baremetal/keiltoolchain.cpp +++ b/src/plugins/baremetal/keiltoolchain.cpp @@ -246,11 +246,7 @@ static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringLis { Process cpp; cpp.setEnvironment(env); - - QStringList args = extraArgs; - args.push_back("-E"); - args.push_back("--list-macros"); - cpp.setCommand({compiler, args}); + cpp.setCommand({compiler, {extraArgs, "-E", "--list-macros"}}); cpp.runBlocking(); if (cpp.result() != ProcessResult::FinishedWithSuccess) { diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 590cfd23276..1e0485d2bf1 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -947,14 +947,11 @@ VcsCommand *BazaarPluginPrivate::createInitialCheckoutCommand(const QString &url const QString &localName, const QStringList &extraArgs) { - QStringList args; - args << m_client.vcsCommandString(BazaarClient::CloneCommand) - << extraArgs << url << localName; - Environment env = m_client.processEnvironment(baseDirectory); env.set("BZR_PROGRESS_BAR", "text"); auto command = VcsBaseClient::createVcsCommand(this, baseDirectory, env); - command->addJob({m_client.vcsBinary(baseDirectory), args}, -1); + command->addJob({m_client.vcsBinary(baseDirectory), + {m_client.vcsCommandString(BazaarClient::CloneCommand), extraArgs, url, localName}}, -1); return command; } diff --git a/src/plugins/clangtools/clangtoolrunner.cpp b/src/plugins/clangtools/clangtoolrunner.cpp index 795135e2856..c91d9e9cfa7 100644 --- a/src/plugins/clangtools/clangtoolrunner.cpp +++ b/src/plugins/clangtools/clangtoolrunner.cpp @@ -161,13 +161,9 @@ GroupItem clangToolTask(const AnalyzeUnits &units, process.setWorkingDirectory(input.outputDirPath); // Current clang-cl puts log file into working dir. const ClangToolStorage &data = *storage; - - const QStringList args = checksArguments(unit, input) - + mainToolArguments(data) - + QStringList{"--"} - + clangArguments(unit, input); - const CommandLine commandLine = {data.executable, args}; - + const CommandLine commandLine{data.executable, {checksArguments(unit, input), + mainToolArguments(data), "--", + clangArguments(unit, input)}}; qCDebug(LOG).noquote() << "Starting" << commandLine.toUserOutput(); process.setCommand(commandLine); }; diff --git a/src/plugins/clangtools/executableinfo.cpp b/src/plugins/clangtools/executableinfo.cpp index 7cda766e7d8..23dc807367d 100644 --- a/src/plugins/clangtools/executableinfo.cpp +++ b/src/plugins/clangtools/executableinfo.cpp @@ -106,15 +106,14 @@ static ClazyChecks querySupportedClazyChecks(const FilePath &executablePath) }; static const QString queryFlag = "-supported-checks-json"; - DataFromProcess<ClazyChecks>::Parameters params(CommandLine(executablePath, {queryFlag}), - parser); + DataFromProcess<ClazyChecks>::Parameters params({executablePath, {queryFlag}}, parser); params.environment.setupEnglishOutput(); params.errorHandler = handleProcessError; auto checks = DataFromProcess<ClazyChecks>::getData(params); if (!checks) { // Some clazy 1.6.x versions have a bug where they expect an argument after the // option. - params.commandLine = CommandLine(executablePath, {queryFlag, "dummy"}); + params.commandLine = {executablePath, {queryFlag, "dummy"}}; checks = DataFromProcess<ClazyChecks>::getData(params); } if (checks) diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index bc4cc82958a..9fa1a06c8a5 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -2265,14 +2265,10 @@ void ClearCasePluginPrivate::diffGraphical(const QString &file1, const QString & QString ClearCasePluginPrivate::runExtDiff(const FilePath &workingDir, const QStringList &arguments, int timeOutS, QTextCodec *outputCodec) { - CommandLine diff("diff"); - diff.addArgs(m_settings.diffArgs.split(' ', Qt::SkipEmptyParts)); - diff.addArgs(arguments); - Process process; process.setWorkingDirectory(workingDir); process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8")); - process.setCommand(diff); + process.setCommand({"diff", {m_settings.diffArgs.split(' ', Qt::SkipEmptyParts), arguments}}); process.runBlocking(seconds(timeOutS), EventLoopMode::On); if (process.result() != ProcessResult::FinishedWithSuccess) return {}; diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 219000f284b..9d81a4f2dfd 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -2056,19 +2056,17 @@ const QList<TestCaseInfo> CMakeBuildSystem::testcasesInfo() const CommandLine CMakeBuildSystem::commandLineForTests(const QList<QString> &tests, const QStringList &options) const { - QStringList args = options; const QSet<QString> testsSet = Utils::toSet(tests); - auto current = Utils::transform<QSet<QString>>(m_testNames, &TestCaseInfo::name); + const auto current = Utils::transform<QSet<QString>>(m_testNames, &TestCaseInfo::name); if (tests.isEmpty() || current == testsSet) - return {m_ctestPath, args}; + return {m_ctestPath, options}; QString testNumbers("0,0,0"); // start, end, stride for (const TestCaseInfo &info : m_testNames) { if (testsSet.contains(info.name)) testNumbers += QString(",%1").arg(info.number); } - args << "-I" << testNumbers; - return {m_ctestPath, args}; + return {m_ctestPath, {options, "-I", testNumbers}}; } DeploymentData CMakeBuildSystem::deploymentDataFromFile() const diff --git a/src/plugins/cppcheck/cppcheckrunner.cpp b/src/plugins/cppcheck/cppcheckrunner.cpp index cf8633c8ddf..7ee44bbb365 100644 --- a/src/plugins/cppcheck/cppcheckrunner.cpp +++ b/src/plugins/cppcheck/cppcheckrunner.cpp @@ -131,7 +131,7 @@ void CppcheckRunner::checkQueued() else m_queue.begin().value() = files; - m_process.setCommand(CommandLine(m_binary, arguments, CommandLine::Raw)); + m_process.setCommand({m_binary, arguments, CommandLine::Raw}); m_process.start(); } diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 24386788dbf..432205ff027 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -282,7 +282,7 @@ void CdbEngine::setupEngine() DebuggerRunParameters sp = runParameters(); if (terminal()) { m_effectiveStartMode = AttachToLocalProcess; - sp.inferior.command = CommandLine(); + sp.inferior.command = {}; sp.attachPID = ProcessHandle(terminal()->applicationPid()); sp.startMode = AttachToLocalProcess; sp.useTerminal = false; // Force no terminal. diff --git a/src/plugins/docker/dockerapi.cpp b/src/plugins/docker/dockerapi.cpp index 537b6c66f38..ea62fd88113 100644 --- a/src/plugins/docker/dockerapi.cpp +++ b/src/plugins/docker/dockerapi.cpp @@ -41,7 +41,7 @@ bool DockerApi::canConnect() bool result = false; - process.setCommand(CommandLine(dockerExe, QStringList{"info"})); + process.setCommand({dockerExe, {"info"}}); connect(&process, &Process::done, [&process, &result] { qCInfo(dockerApiLog) << "'docker info' result:\n" << qPrintable(process.allOutput()); if (process.result() == ProcessResult::FinishedWithSuccess) @@ -115,8 +115,7 @@ QFuture<Utils::expected_str<QList<Network>>> DockerApi::networks() if (dockerExe.isEmpty() || !dockerExe.isExecutableFile()) return make_unexpected(Tr::tr("Docker executable not found")); - process.setCommand( - CommandLine(dockerExe, QStringList{"network", "ls", "--format", "{{json .}}"})); + process.setCommand({dockerExe, {"network", "ls", "--format", "{{json .}}"}}); process.runBlocking(); if (process.result() != ProcessResult::FinishedWithSuccess) { diff --git a/src/plugins/fossil/fossilplugin.cpp b/src/plugins/fossil/fossilplugin.cpp index d627d13fdaf..8bf61894af7 100644 --- a/src/plugins/fossil/fossilplugin.cpp +++ b/src/plugins/fossil/fossilplugin.cpp @@ -958,12 +958,9 @@ VcsCommand *FossilPluginPrivate::createInitialCheckoutCommand(const QString &sou // // So here we want Fossil to save the remote details when specified. - QStringList args; - args << fossilClient().vcsCommandString(FossilClient::CloneCommand) - << extraOptions - << sourceUrl - << fossilFileNative; - command->addJob({fossilClient().vcsBinary(checkoutPath), args}, -1); + command->addJob({fossilClient().vcsBinary(checkoutPath), + {fossilClient().vcsCommandString(FossilClient::CloneCommand), extraOptions, + sourceUrl, fossilFileNative}}, -1); } // check out the cloned repository file into the working copy directory; @@ -977,15 +974,14 @@ VcsCommand *FossilPluginPrivate::createInitialCheckoutCommand(const QString &sou // set user default to admin user if specified if (!isLocalRepository && !adminUser.isEmpty()) { - const QStringList args({ "user", "default", adminUser, "--user", adminUser}); - command->addJob({fossilClient().vcsBinary(checkoutPath), args}, -1); + command->addJob({fossilClient().vcsBinary(checkoutPath), + {"user", "default", adminUser, "--user", adminUser}}, -1); } // turn-off autosync if requested - if (!isLocalRepository - && disableAutosync) { - const QStringList args({"settings", "autosync", "off"}); - command->addJob({fossilClient().vcsBinary(checkoutPath), args}, -1); + if (!isLocalRepository && disableAutosync) { + command->addJob({fossilClient().vcsBinary(checkoutPath), {"settings", "autosync", "off"}}, + -1); } return command; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index af5b267101a..d238f7113eb 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -1766,13 +1766,11 @@ VcsCommand *GitPluginPrivate::createInitialCheckoutCommand(const QString &url, const QString &localName, const QStringList &extraArgs) { - QStringList args = {"clone", "--progress"}; - args << extraArgs << url << localName; - auto command = VcsBaseClient::createVcsCommand(this, baseDirectory, gitClient().processEnvironment(baseDirectory)); command->addFlags(RunFlags::SuppressStdErr); - command->addJob({gitClient().vcsBinary(baseDirectory), args}, -1); + command->addJob({gitClient().vcsBinary(baseDirectory), + {"clone", "--progress", extraArgs, url, localName}}, -1); return command; } diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp index d0a102c9df4..138943ef2cc 100644 --- a/src/plugins/git/mergetool.cpp +++ b/src/plugins/git/mergetool.cpp @@ -35,9 +35,7 @@ MergeTool::MergeTool(QObject *parent) : QObject(parent) void MergeTool::start(const FilePath &workingDirectory, const QStringList &files) { - QStringList arguments; - arguments << "mergetool" << "-y" << files; - const CommandLine cmd = {gitClient().vcsBinary(workingDirectory), arguments}; + const CommandLine cmd{gitClient().vcsBinary(workingDirectory), {"mergetool", "-y", files}}; VcsOutputWindow::appendCommand(workingDirectory, cmd); m_process.setCommand(cmd); m_process.setWorkingDirectory(workingDirectory); diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index e5b03e5229e..863a2867b8a 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -237,17 +237,17 @@ GroupItem DeviceCtlRunner::launchTask(const QString &bundleIdentifier) return SetupResult::StopWithError; } process.setCommand({FilePath::fromString("/usr/bin/xcrun"), - QStringList{"devicectl", - "device", - "process", - "launch", - "--device", - m_device->uniqueInternalDeviceId(), - "--quiet", - "--json-output", - "-", - bundleIdentifier} - + m_arguments}); + {"devicectl", + "device", + "process", + "launch", + "--device", + m_device->uniqueInternalDeviceId(), + "--quiet", + "--json-output", + "-", + bundleIdentifier, + m_arguments}}); return SetupResult::Continue; }; const auto onDone = [this](const Process &process, DoneWith result) { diff --git a/src/plugins/ios/simulatorcontrol.cpp b/src/plugins/ios/simulatorcontrol.cpp index 4def4c0e471..b702767251e 100644 --- a/src/plugins/ios/simulatorcontrol.cpp +++ b/src/plugins/ios/simulatorcontrol.cpp @@ -86,20 +86,18 @@ static expected_str<void> runCommand( } static expected_str<void> runSimCtlCommand( - QStringList args, + const QStringList &args, QString *output, QString *allOutput = nullptr, std::function<bool()> shouldStop = [] { return false; }) { - args.prepend("simctl"); - // Cache xcrun's path, as this function will be called often. static FilePath xcrun = FilePath::fromString("xcrun").searchInPath(); if (xcrun.isEmpty()) return make_unexpected(Tr::tr("Cannot find xcrun.")); else if (!xcrun.isExecutableFile()) return make_unexpected(Tr::tr("xcrun is not executable.")); - return runCommand({xcrun, args}, output, allOutput, shouldStop); + return runCommand({xcrun, {"simctl", args}}, output, allOutput, shouldStop); } static expected_str<void> launchSimulator(const QString &simUdid, std::function<bool()> shouldStop) diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index f87d181da41..f3c63547fa7 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -734,11 +734,9 @@ VcsCommand *MercurialPluginPrivate::createInitialCheckoutCommand(const QString & const QString &localName, const QStringList &extraArgs) { - QStringList args; - args << QLatin1String("clone") << extraArgs << url << localName; auto command = VcsBaseClient::createVcsCommand(this, baseDirectory, mercurialClient().processEnvironment(baseDirectory)); - command->addJob({settings().binaryPath(), args}, -1); + command->addJob({settings().binaryPath(), {"clone", extraArgs, url, localName}}, -1); return command; } diff --git a/src/plugins/perforce/perforcechecker.cpp b/src/plugins/perforce/perforcechecker.cpp index cf63d9e6913..9eb66ef45c0 100644 --- a/src/plugins/perforce/perforcechecker.cpp +++ b/src/plugins/perforce/perforcechecker.cpp @@ -52,8 +52,7 @@ void PerforceChecker::resetOverrideCursor() } void PerforceChecker::start(const FilePath &binary, const FilePath &workingDirectory, - const QStringList &basicArgs, - int timeoutMS) + const QStringList &basicArgs, int timeoutMS) { if (isRunning()) { emitFailed(QLatin1String("Internal error: process still running")); @@ -64,13 +63,10 @@ void PerforceChecker::start(const FilePath &binary, const FilePath &workingDirec return; } m_binary = binary; - QStringList args = basicArgs; - args << QLatin1String("client") << QLatin1String("-o"); - if (!workingDirectory.isEmpty()) m_process.setWorkingDirectory(workingDirectory); - m_process.setCommand({m_binary, args}); + m_process.setCommand({m_binary, {basicArgs, "client", "-o"}}); m_process.start(); // Timeout handling m_timeOutMS = timeoutMS; diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index d15dd465c37..b7568d4275c 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -379,7 +379,7 @@ void ProcessExtraCompiler::runInThread(QPromise<FileNameToContentsHash> &promise process.setEnvironment(env); if (!workDir.isEmpty()) process.setWorkingDirectory(workDir); - process.setCommand({ cmd, args }); + process.setCommand({cmd, args}); process.setWriteData(sourceContents); process.start(); if (!process.waitForStarted()) diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 310e170e5a5..9dad5e8eb67 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -1793,11 +1793,7 @@ Macros ClangClToolchain::msvcPredefinedMacros(const QStringList &cxxflags, Process cpp; cpp.setEnvironment(env); cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryFilePath()); - - QStringList arguments = cxxflags; - arguments.append(gccPredefinedMacrosOptions(language())); - arguments.append("-"); - cpp.setCommand({compilerCommand(), arguments}); + cpp.setCommand({compilerCommand(), {cxxflags, gccPredefinedMacrosOptions(language()), "-"}}); cpp.runBlocking(); if (cpp.result() != ProcessResult::FinishedWithSuccess) { // Show the warning but still parse the output. diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 2e4cd4ed585..87156e3b9cc 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -121,11 +121,9 @@ void openPythonRepl(QObject *parent, const FilePath &file, ReplType type) return file.absolutePath(); }; - const auto args = QStringList{"-i"} + replImportArgs(file, type); const FilePath pythonCommand = detectPython(file); - Process process; - process.setCommand({pythonCommand, args}); + process.setCommand({pythonCommand, {"-i", replImportArgs(file, type)}}); process.setWorkingDirectory(workingDir(file)); process.setTerminalMode(TerminalMode::Detached); process.start(); @@ -201,7 +199,7 @@ static bool isUsableHelper(QHash<FilePath, bool> *cache, const QString &keyStrin if (it == cache->end()) { const Key key = keyFromString(keyString); Process process; - process.setCommand({python, QStringList{"-m", commandArg, "-h"}}); + process.setCommand({python, {"-m", commandArg, "-h"}}); process.runBlocking(); const bool usable = process.result() == ProcessResult::FinishedWithSuccess; it = cache->insert(python, usable); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index e012499b540..19e5d49b51d 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -188,7 +188,7 @@ bool QMakeStep::init() else workingDirectory = qmakeBc->buildDirectory(); - m_qmakeCommand = CommandLine{qtVersion->qmakeFilePath(), allArguments(qtVersion), CommandLine::Raw}; + m_qmakeCommand = {qtVersion->qmakeFilePath(), allArguments(qtVersion), CommandLine::Raw}; m_runMakeQmake = (qtVersion->qtVersion() >= QVersionNumber(5, 0 ,0)); // The Makefile is used by qmake and make on the build device, from that @@ -216,7 +216,7 @@ bool QMakeStep::init() OutputFormat::ErrorMessage); return false; } - m_makeCommand = CommandLine{make, makeArguments(makeFile.path()), CommandLine::Raw}; + m_makeCommand = {make, makeArguments(makeFile.path()), CommandLine::Raw}; } else { m_makeCommand = {}; } diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 8490d6b2c2c..d2779e2ebb8 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -470,12 +470,10 @@ qint64 SshProcessInterface::processId() const ProcessResult SshProcessInterface::runInShell(const CommandLine &command, const QByteArray &data) { Process process; - CommandLine cmd = {d->m_device->filePath("/bin/sh"), {"-c"}}; QString tmp; ProcessArgs::addArg(&tmp, command.executable().path()); ProcessArgs::addArgs(&tmp, command.arguments()); - cmd.addArg(tmp); - process.setCommand(cmd); + process.setCommand({d->m_device->filePath("/bin/sh"), {"-c", tmp}}); process.setWriteData(data); using namespace std::chrono_literals; process.runBlocking(2s); @@ -524,7 +522,7 @@ void SshProcessInterface::handleSendControlSignal(ControlSignal controlSignal) QTC_ASSERT(pid, return); // TODO: try sending a signal based on process name const QString args = QString::fromLatin1("-%1 -%2") .arg(controlSignalToInt(controlSignal)).arg(pid); - const CommandLine command = { "kill", args, CommandLine::Raw }; + const CommandLine command{"kill", args, CommandLine::Raw}; // Killing by using the pid as process group didn't work // Fallback to killing the pid directly @@ -532,7 +530,7 @@ void SshProcessInterface::handleSendControlSignal(ControlSignal controlSignal) if (runInShell(command, {}) != ProcessResult::FinishedWithSuccess) { const QString args = QString::fromLatin1("-%1 %2") .arg(controlSignalToInt(controlSignal)).arg(pid); - const CommandLine command = { "kill" , args, CommandLine::Raw }; + const CommandLine command{"kill" , args, CommandLine::Raw}; runInShell(command, {}); } } @@ -1487,7 +1485,7 @@ private: if (file.m_targetPermissions == FilePermissions::ForceExecutable) batchData += "chmod 1775 " + target + '\n'; } - process().setCommand({sftpBinary, fullConnectionOptions() << "-b" << "-" << host()}); + process().setCommand({sftpBinary, {fullConnectionOptions(), "-b", "-", host()}}); process().setWriteData(batchData); process().start(); } diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index 38edbb6791e..8b678bea961 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -245,7 +245,7 @@ void MakeInstallStep::updateArgsFromAspect() void MakeInstallStep::updateFullCommandLine() { - CommandLine cmd{makeExecutable(), userArguments(), CommandLine::Raw}; + const CommandLine cmd{makeExecutable(), userArguments(), CommandLine::Raw}; m_fullCommand.setValue(cmd.toUserOutput()); } diff --git a/src/plugins/remotelinux/sshkeycreationdialog.cpp b/src/plugins/remotelinux/sshkeycreationdialog.cpp index 03c6f7a543f..a94a56cf61e 100644 --- a/src/plugins/remotelinux/sshkeycreationdialog.cpp +++ b/src/plugins/remotelinux/sshkeycreationdialog.cpp @@ -110,11 +110,11 @@ void SshKeyCreationDialog::generateKeys() const QString keyTypeString = QLatin1String(m_rsa->isChecked() ? "rsa": "ecdsa"); QApplication::setOverrideCursor(Qt::BusyCursor); Process keygen; - const QStringList args{"-t", keyTypeString, "-b", m_comboBox->currentText(), - "-N", QString(), "-f", privateKeyFilePath().path()}; - QString errorMsg; - keygen.setCommand({SshSettings::keygenFilePath(), args}); + keygen.setCommand({SshSettings::keygenFilePath(), + {"-t", keyTypeString, "-b", m_comboBox->currentText(), "-N", QString(), "-f", + privateKeyFilePath().path()}}); keygen.start(); + QString errorMsg; if (!keygen.waitForFinished()) errorMsg = keygen.errorString(); else if (keygen.exitCode() != 0) diff --git a/src/plugins/screenrecorder/cropandtrim.cpp b/src/plugins/screenrecorder/cropandtrim.cpp index 4f65469e62b..b6da8f092ea 100644 --- a/src/plugins/screenrecorder/cropandtrim.cpp +++ b/src/plugins/screenrecorder/cropandtrim.cpp @@ -698,7 +698,7 @@ void CropAndTrimDialog::startFrameFetch() if (m_nextFetchFrame == -1) return; - const CommandLine cl = { + const CommandLine cl{ Internal::settings().ffmpegTool(), { "-v", "error", diff --git a/src/plugins/screenrecorder/ffmpegutils.cpp b/src/plugins/screenrecorder/ffmpegutils.cpp index fa0a6f45ae7..9f1abb8ec80 100644 --- a/src/plugins/screenrecorder/ffmpegutils.cpp +++ b/src/plugins/screenrecorder/ffmpegutils.cpp @@ -152,7 +152,7 @@ static QVersionNumber parseVersionNumber(const QByteArray &toolOutput) QVersionNumber toolVersion() { Process proc; - const CommandLine cl = { + const CommandLine cl{ Internal::settings().ffprobeTool(), { "-v", "quiet", @@ -201,7 +201,7 @@ static ClipInfo parseClipInfo(const QByteArray &toolOutput) ClipInfo clipInfo(const FilePath &path) { Process proc; - const CommandLine cl = { + const CommandLine cl{ Internal::settings().ffprobeTool(), { "-v", "quiet", diff --git a/src/plugins/squish/squishserverprocess.cpp b/src/plugins/squish/squishserverprocess.cpp index 9e4b9741433..3af7bf308a6 100644 --- a/src/plugins/squish/squishserverprocess.cpp +++ b/src/plugins/squish/squishserverprocess.cpp @@ -26,9 +26,8 @@ void SquishServerProcess::stop() { if (m_process.state() != QProcess::NotRunning && m_serverPort > 0) { Utils::Process serverKiller; - QStringList args; - args << "--stop" << "--port" << QString::number(m_serverPort); - serverKiller.setCommand({m_process.commandLine().executable(), args}); + serverKiller.setCommand({m_process.commandLine().executable(), + {"--stop", "--port", QString::number(m_serverPort)}}); serverKiller.setEnvironment(m_process.environment()); serverKiller.start(); if (!serverKiller.waitForFinished()) { diff --git a/src/plugins/squish/squishtools.cpp b/src/plugins/squish/squishtools.cpp index f6ef2e67e07..68dabd6449f 100644 --- a/src/plugins/squish/squishtools.cpp +++ b/src/plugins/squish/squishtools.cpp @@ -554,8 +554,8 @@ void SquishTools::startSquishServer(Request request) m_perspective.updateStatus(Tr::tr("Running test case")); } - const QStringList arguments = serverArgumentsFromSettings(); - m_serverProcess.start({toolsSettings.serverPath, arguments}, squishEnvironment()); + m_serverProcess.start({toolsSettings.serverPath, serverArgumentsFromSettings()}, + squishEnvironment()); } void SquishTools::stopSquishServer() @@ -569,13 +569,10 @@ void SquishTools::startSquishRunner() if (!isValidToStartRunner() || !setupRunnerPath()) return; - const QStringList args = runnerArgumentsFromSettings(); - if (m_request == RecordTestRequested) m_closeRunnerOnEndRecord = true; - Utils::CommandLine cmdLine = {toolsSettings.runnerPath, args}; - setupAndStartSquishRunnerProcess(cmdLine); + setupAndStartSquishRunnerProcess({toolsSettings.runnerPath, runnerArgumentsFromSettings()}); } void SquishTools::setupAndStartRecorder() @@ -604,7 +601,7 @@ void SquishTools::setupAndStartRecorder() m_secondaryRunner = new SquishRunnerProcess(this); m_secondaryRunner->setupProcess(SquishRunnerProcess::Record); - const CommandLine cmd = {toolsSettings.runnerPath, args}; + const CommandLine cmd{toolsSettings.runnerPath, args}; connect(m_secondaryRunner, &SquishRunnerProcess::recorderDone, this, &SquishTools::onRecorderFinished); qCDebug(LOG) << "Recorder starting:" << cmd.toUserOutput(); @@ -629,7 +626,7 @@ void SquishTools::setupAndStartInspector() m_secondaryRunner = new SquishRunnerProcess(this); m_secondaryRunner->setupProcess(SquishRunnerProcess::Inspect); - const CommandLine cmd = {toolsSettings.runnerPath, args}; + const CommandLine cmd{toolsSettings.runnerPath, args}; connect(m_secondaryRunner, &SquishRunnerProcess::logOutputReceived, this, &SquishTools::logOutputReceived); connect(m_secondaryRunner, &SquishRunnerProcess::objectPicked, @@ -676,8 +673,8 @@ void SquishTools::executeRunnerQuery() if (!isValidToStartRunner() || !setupRunnerPath()) return; - QStringList arguments = { "--port", QString::number(m_serverProcess.port()) }; - Utils::CommandLine cmdLine = {toolsSettings.runnerPath, arguments}; + CommandLine cmdLine{toolsSettings.runnerPath, + {"--port", QString::number(m_serverProcess.port())}}; switch (m_query) { case ServerInfo: cmdLine.addArg("--info"); @@ -690,7 +687,7 @@ void SquishTools::executeRunnerQuery() case SetGlobalScriptDirs: cmdLine.addArg("--config"); cmdLine.addArg("setGlobalScriptDirs"); - cmdLine.addArgs(m_queryParameter, Utils::CommandLine::Raw); + cmdLine.addArgs(m_queryParameter, CommandLine::Raw); break; default: QTC_ASSERT(false, return); @@ -1106,10 +1103,9 @@ void SquishTools::interruptRunner() { qCDebug(LOG) << "Interrupting runner"; QTC_ASSERT(m_primaryRunner, return); - qint64 processId = m_primaryRunner->processId(); - const CommandLine cmd(toolsSettings.processComPath, {QString::number(processId), "break"}); + const qint64 processId = m_primaryRunner->processId(); Process process; - process.setCommand(cmd); + process.setCommand({toolsSettings.processComPath, {QString::number(processId), "break"}}); process.start(); process.waitForFinished(); } @@ -1122,10 +1118,9 @@ void SquishTools::terminateRunner() m_perspective.updateStatus(Tr::tr("User stop initiated.")); // should we terminate the AUT instead of the runner?!? QTC_ASSERT(m_primaryRunner, return); - qint64 processId = m_primaryRunner->processId(); - const CommandLine cmd(toolsSettings.processComPath, {QString::number(processId), "terminate"}); + const qint64 processId = m_primaryRunner->processId(); Process process; - process.setCommand(cmd); + process.setCommand({toolsSettings.processComPath, {QString::number(processId), "terminate"}}); process.start(); process.waitForFinished(); } @@ -1263,7 +1258,7 @@ bool SquishTools::setupRunnerPath() return true; } -void SquishTools::setupAndStartSquishRunnerProcess(const Utils::CommandLine &cmdLine) +void SquishTools::setupAndStartSquishRunnerProcess(const CommandLine &cmdLine) { QTC_ASSERT(m_primaryRunner, return); // avoid crashes on fast re-usage of Process diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index e69809143d3..1dfb19ed860 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -115,6 +115,7 @@ CommandLine &operator<<(Utils::CommandLine &command, SubversionClient::AddAuthOp QString SubversionClient::synchronousTopic(const FilePath &repository) const { + // TODO: Looks unused QStringList args; QString svnVersionBinary = vcsBinary(repository).toString(); diff --git a/src/plugins/terminal/shellintegration.cpp b/src/plugins/terminal/shellintegration.cpp index 5dfd450e68c..1303f922884 100644 --- a/src/plugins/terminal/shellintegration.cpp +++ b/src/plugins/terminal/shellintegration.cpp @@ -133,7 +133,7 @@ void ShellIntegration::onOsc(int cmd, std::string_view str, bool initial, bool f qCDebug(integrationLog) << "OSC 133:" << data; } else if (cmd == 633 && command.length() == 1) { if (command[0] == 'E') { - CommandLine cmdLine = CommandLine::fromUserInput(data.toString()); + const CommandLine cmdLine = CommandLine::fromUserInput(data.toString()); emit commandChanged(cmdLine); } else if (command[0] == 'D') { emit commandChanged({}); @@ -174,12 +174,10 @@ void ShellIntegration::prepareProcess(Utils::Process &process) m_tempDir.filePath(filesToCopy.bash.rcFile.fileName())); rcPath.copyFile(tmpRc); - CommandLine newCmd = {cmd.executable(), {"--init-file", tmpRc.nativePath()}}; - if (cmd.arguments() == "-l") env.set("VSCODE_SHELL_LOGIN", "1"); - cmd = newCmd; + cmd = {cmd.executable(), {"--init-file", tmpRc.nativePath()}}; } else if (cmd.executable().baseName() == "zsh") { for (const FileToCopy &file : filesToCopy.zsh.files) { const auto copyResult = file.source.copyFile( diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp index a314d0babec..c6c97ae9bde 100644 --- a/src/plugins/terminal/terminalwidget.cpp +++ b/src/plugins/terminal/terminalwidget.cpp @@ -83,7 +83,7 @@ void TerminalWidget::setupPty() { m_process = std::make_unique<Process>(); - CommandLine shellCommand = m_openParameters.shellCommand.value_or( + const CommandLine shellCommand = m_openParameters.shellCommand.value_or( CommandLine{settings().shell(), settings().shellArguments(), CommandLine::Raw}); if (shellCommand.executable().isRootPath()) { diff --git a/src/plugins/valgrind/valgrindmemcheckparsertest.cpp b/src/plugins/valgrind/valgrindmemcheckparsertest.cpp index ee87ded6847..90d1f27ca0d 100644 --- a/src/plugins/valgrind/valgrindmemcheckparsertest.cpp +++ b/src/plugins/valgrind/valgrindmemcheckparsertest.cpp @@ -187,9 +187,9 @@ void ValgrindMemcheckParserTest::initTest(const QString &testfile, const QString QVERIFY2(fileInfo.isExecutable(), qPrintable(fakeValgrind)); QVERIFY2(!fileInfo.isDir(), qPrintable(fakeValgrind)); - const QStringList args = {QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()), - "-i", testfile}; - m_process->setCommand({FilePath::fromString(fakeValgrind), args + otherArgs}); + m_process->setCommand({FilePath::fromString(fakeValgrind), + {QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()), + "-i", testfile, otherArgs}}); m_process->start(); using namespace std::chrono_literals; diff --git a/src/plugins/valgrind/valgrindtestrunnertest.cpp b/src/plugins/valgrind/valgrindtestrunnertest.cpp index 7d53efca33d..863265f8d04 100644 --- a/src/plugins/valgrind/valgrindtestrunnertest.cpp +++ b/src/plugins/valgrind/valgrindtestrunnertest.cpp @@ -93,11 +93,8 @@ QString ValgrindTestRunnerTest::runTestBinary(const QString &binary, const QStri debuggee.command.setExecutable(Utils::FilePath::fromString(binPath)); debuggee.environment = Utils::Environment::systemEnvironment(); - CommandLine valgrind{"valgrind", {"--num-callers=50", "--track-origins=yes"}}; - valgrind.addArgs(vArgs); - m_runner->setLocalServerAddress(QHostAddress::LocalHost); - m_runner->setValgrindCommand(valgrind); + m_runner->setValgrindCommand({"valgrind", {"--num-callers=50", "--track-origins=yes", vArgs}}); m_runner->setDebuggee(debuggee); m_runner->runBlocking(); return binPath; |