CommandLine: Reuse new c'tor

Change-Id: Id154881b4f5d8c488e5c1f5e0f843d36bf838759
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2024-05-16 14:07:59 +02:00
parent d857af4cec
commit 982ad24243
39 changed files with 104 additions and 165 deletions

View File

@@ -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;

View File

@@ -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())

View File

@@ -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());

View File

@@ -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});

View File

@@ -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();

View File

@@ -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 {};

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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);
};

View File

@@ -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)

View File

@@ -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 {};

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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.

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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())

View File

@@ -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.

View File

@@ -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);

View File

@@ -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 = {};
}

View File

@@ -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();
}

View File

@@ -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());
}

View File

@@ -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)

View File

@@ -698,7 +698,7 @@ void CropAndTrimDialog::startFrameFetch()
if (m_nextFetchFrame == -1)
return;
const CommandLine cl = {
const CommandLine cl{
Internal::settings().ffmpegTool(),
{
"-v", "error",

View File

@@ -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",

View File

@@ -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()) {

View File

@@ -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

View File

@@ -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();

View File

@@ -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(

View File

@@ -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()) {

View File

@@ -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;

View File

@@ -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;