Core: Use Utils::CommandLine in ExecuteFilter

... using a new CommandLine::fromUserInput convenience function.

Change-Id: Ic786530af89ec80f4211e66f36caa22cb705effe
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2021-08-20 10:05:13 +02:00
parent 20a63d6c7e
commit d119c717c1
4 changed files with 28 additions and 19 deletions

View File

@@ -26,6 +26,7 @@
#include "commandline.h"
#include "environment.h"
#include "macroexpander.h"
#include "qtcassert.h"
#include "stringutils.h"
@@ -1434,6 +1435,21 @@ CommandLine::CommandLine(const FilePath &exe, const QString &args, RawType)
addArgs(args, Raw);
}
CommandLine CommandLine::fromUserInput(const QString &cmdline, MacroExpander *expander)
{
CommandLine cmd;
const int pos = cmdline.indexOf(' ');
if (pos == -1) {
cmd.m_executable = FilePath::fromString(cmdline);
} else {
cmd.m_executable = FilePath::fromString(cmdline.left(pos));
cmd.m_arguments = cmdline.right(cmdline.length() - pos - 1);
if (expander)
cmd.m_arguments = expander->expand(cmd.m_arguments);
}
return cmd;
}
void CommandLine::addArg(const QString &arg)
{
ProcessArgs::addArg(&m_arguments, arg, m_executable.osType());