Utils: Add CommandLine::addArgs(const CommandLine &cmd) convenience

This adds cmd's executable and arguments one by one to this commandline.
Useful to construct command lines for 'sudo', 'nice', etc.

Change-Id: I76067bc10e269b8e7ff4d945449be3633b321281
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2021-02-16 12:53:34 +01:00
parent 01d7fcd8d8
commit 32394632d2
2 changed files with 9 additions and 0 deletions

View File

@@ -106,6 +106,14 @@ void CommandLine::addArgs(const QStringList &inArgs, OsType osType)
addArg(arg, osType);
}
// Adds cmd's executable and arguments one by one to this commandline.
// Useful for 'sudo', 'nice', etc
void CommandLine::addArgs(const CommandLine &cmd, OsType osType)
{
addArg(cmd.executable().toString());
addArgs(cmd.splitArguments(osType));
}
void CommandLine::addArgs(const QString &inArgs, RawType)
{
QtcProcess::addArgs(&m_arguments, inArgs);

View File

@@ -148,6 +148,7 @@ public:
void addArg(const QString &arg, OsType osType = HostOsInfo::hostOs());
void addArgs(const QStringList &inArgs, OsType osType = HostOsInfo::hostOs());
void addArgs(const CommandLine &cmd, OsType osType = HostOsInfo::hostOs());
void addArgs(const QString &inArgs, RawType);