forked from qt-creator/qt-creator
Utils: Introduce QtcProcess::toStandaloneCommandLine()
The goal is to make a QtcProcess incl. environment, working directory, executable and arguments testable, e.g. in a terminal. The new toStandaloneCommandLine() returns a string containing the command line for a call of "env" the data of the QtcProcess instance as parameters. To be used like: qDebug().noquote() << qtcProc.toStandaloneCommandLine(); ..and the debug output can be pasted into a terminal. Change-Id: Ib6cbea290e1eff3279d6e0a67076a624312af879 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -832,6 +832,25 @@ void QtcProcess::setStandardInputFile(const QString &inputFile)
|
||||
d->m_process->setStandardInputFile(inputFile);
|
||||
}
|
||||
|
||||
QString QtcProcess::toStandaloneCommandLine() const
|
||||
{
|
||||
QStringList parts;
|
||||
parts.append("/usr/bin/env");
|
||||
if (!d->m_workingDirectory.isEmpty()) {
|
||||
parts.append("-C");
|
||||
d->m_workingDirectory.path();
|
||||
}
|
||||
parts.append("-i");
|
||||
if (d->m_environment.size() > 0) {
|
||||
const QStringList envVars = d->m_environment.toStringList();
|
||||
std::transform(envVars.cbegin(), envVars.cend(),
|
||||
std::back_inserter(parts), ProcessArgs::quoteArgUnix);
|
||||
}
|
||||
parts.append(d->m_commandLine.executable().path());
|
||||
parts.append(d->m_commandLine.splitArguments());
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
void QtcProcess::setRemoteProcessHooks(const DeviceProcessHooks &hooks)
|
||||
{
|
||||
s_deviceHooks = hooks;
|
||||
|
@@ -193,6 +193,8 @@ public:
|
||||
|
||||
void setStandardInputFile(const QString &inputFile);
|
||||
|
||||
QString toStandaloneCommandLine() const;
|
||||
|
||||
signals:
|
||||
void started();
|
||||
void finished();
|
||||
|
Reference in New Issue
Block a user