forked from qt-creator/qt-creator
Move CommandLine out of fileutils.h
to ProcessArgs and rename the files to commandline.*. fileutils was a strange place for CommandLine, and this reduces the dependencies needed for sdktool. Change-Id: I9d7e8ffe8a3560f5d12934457b086f9446976883 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
#include "sshsettings.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/processargs.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QByteArrayList>
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/processargs.h>
|
||||
#include <utils/commandline.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "sshlogging_p.h"
|
||||
#include "sshsettings.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
|
@@ -28,7 +28,9 @@
|
||||
#include "ssh_global.h"
|
||||
#include "sshprocess.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
namespace Utils {
|
||||
class CommandLine;
|
||||
}
|
||||
|
||||
namespace QSsh {
|
||||
class SshConnection;
|
||||
|
@@ -24,6 +24,7 @@ add_qtc_library(Utils
|
||||
checkablemessagebox.cpp checkablemessagebox.h
|
||||
classnamevalidatinglineedit.cpp classnamevalidatinglineedit.h
|
||||
codegeneration.cpp codegeneration.h
|
||||
commandline.cpp commandline.h
|
||||
completinglineedit.cpp completinglineedit.h
|
||||
completingtextedit.cpp completingtextedit.h
|
||||
consoleprocess.cpp consoleprocess.h
|
||||
@@ -115,7 +116,6 @@ add_qtc_library(Utils
|
||||
porting.h
|
||||
portlist.cpp portlist.h
|
||||
predicates.h
|
||||
processargs.cpp processargs.h
|
||||
processhandle.cpp processhandle.h
|
||||
progressindicator.cpp progressindicator.h
|
||||
projectintropage.cpp projectintropage.h projectintropage.ui
|
||||
|
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "processargs.h"
|
||||
#include "commandline.h"
|
||||
|
||||
#include "environment.h"
|
||||
#include "qtcassert.h"
|
||||
@@ -1409,4 +1409,74 @@ QString ProcessArgs::toString() const
|
||||
return ProcessArgs::joinArgs(m_unixArgs, OsTypeLinux);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class Utils::CommandLine
|
||||
|
||||
\brief The CommandLine class represents a command line of a QProcess or
|
||||
similar utility.
|
||||
*/
|
||||
|
||||
CommandLine::CommandLine() = default;
|
||||
|
||||
CommandLine::CommandLine(const QString &executable)
|
||||
: m_executable(FilePath::fromString(executable))
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &executable)
|
||||
: m_executable(executable)
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const QString &exe, const QStringList &args)
|
||||
: CommandLine(FilePath::fromString(exe), args)
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &exe, const QStringList &args)
|
||||
: m_executable(exe)
|
||||
{
|
||||
addArgs(args);
|
||||
}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &exe, const QString &args, RawType)
|
||||
: m_executable(exe)
|
||||
{
|
||||
addArgs(args, Raw);
|
||||
}
|
||||
|
||||
void CommandLine::addArg(const QString &arg, OsType osType)
|
||||
{
|
||||
ProcessArgs::addArg(&m_arguments, arg, osType);
|
||||
}
|
||||
|
||||
void CommandLine::addArgs(const QStringList &inArgs, OsType osType)
|
||||
{
|
||||
for (const QString &arg : inArgs)
|
||||
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)
|
||||
{
|
||||
ProcessArgs::addArgs(&m_arguments, inArgs);
|
||||
}
|
||||
|
||||
QString CommandLine::toUserOutput() const
|
||||
{
|
||||
QString res = m_executable.toUserOutput();
|
||||
if (!m_arguments.isEmpty())
|
||||
res += ' ' + m_arguments;
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList CommandLine::splitArguments(OsType osType) const
|
||||
{
|
||||
return ProcessArgs::splitArgs(m_arguments, osType);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include "fileutils.h"
|
||||
#include "hostosinfo.h"
|
||||
|
||||
#include <QStringList>
|
||||
@@ -130,4 +131,35 @@ private:
|
||||
bool m_isWindows;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT CommandLine
|
||||
{
|
||||
public:
|
||||
enum RawType { Raw };
|
||||
|
||||
CommandLine();
|
||||
explicit CommandLine(const QString &executable);
|
||||
explicit CommandLine(const FilePath &executable);
|
||||
CommandLine(const QString &exe, const QStringList &args);
|
||||
CommandLine(const FilePath &exe, const QStringList &args);
|
||||
CommandLine(const FilePath &exe, const QString &unparsedArgs, RawType);
|
||||
|
||||
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);
|
||||
|
||||
QString toUserOutput() const;
|
||||
|
||||
FilePath executable() const { return m_executable; }
|
||||
QString arguments() const { return m_arguments; }
|
||||
QStringList splitArguments(OsType osType = HostOsInfo::hostOs()) const;
|
||||
|
||||
private:
|
||||
FilePath m_executable;
|
||||
QString m_arguments;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Q_DECLARE_METATYPE(Utils::CommandLine)
|
@@ -28,7 +28,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/processargs.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/winutils.h>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include "savefile.h"
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "processargs.h"
|
||||
#include "commandline.h"
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include <QDataStream>
|
||||
@@ -65,76 +65,6 @@ namespace Utils {
|
||||
|
||||
static DeviceFileHooks s_deviceHooks;
|
||||
|
||||
/*! \class Utils::CommandLine
|
||||
|
||||
\brief The CommandLine class represents a command line of a QProcess
|
||||
or similar utility.
|
||||
|
||||
*/
|
||||
|
||||
CommandLine::CommandLine() = default;
|
||||
|
||||
CommandLine::CommandLine(const QString &executable)
|
||||
: m_executable(FilePath::fromString(executable))
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &executable)
|
||||
: m_executable(executable)
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const QString &exe, const QStringList &args)
|
||||
: CommandLine(FilePath::fromString(exe), args)
|
||||
{}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &exe, const QStringList &args)
|
||||
: m_executable(exe)
|
||||
{
|
||||
addArgs(args);
|
||||
}
|
||||
|
||||
CommandLine::CommandLine(const FilePath &exe, const QString &args, RawType)
|
||||
: m_executable(exe)
|
||||
{
|
||||
addArgs(args, Raw);
|
||||
}
|
||||
|
||||
void CommandLine::addArg(const QString &arg, OsType osType)
|
||||
{
|
||||
ProcessArgs::addArg(&m_arguments, arg, osType);
|
||||
}
|
||||
|
||||
void CommandLine::addArgs(const QStringList &inArgs, OsType osType)
|
||||
{
|
||||
for (const QString &arg : inArgs)
|
||||
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)
|
||||
{
|
||||
ProcessArgs::addArgs(&m_arguments, inArgs);
|
||||
}
|
||||
|
||||
QString CommandLine::toUserOutput() const
|
||||
{
|
||||
QString res = m_executable.toUserOutput();
|
||||
if (!m_arguments.isEmpty())
|
||||
res += ' ' + m_arguments;
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList CommandLine::splitArguments(OsType osType) const
|
||||
{
|
||||
return ProcessArgs::splitArgs(m_arguments, osType);
|
||||
}
|
||||
|
||||
/*! \class Utils::FileUtils
|
||||
|
||||
\brief The FileUtils class contains file and directory related convenience
|
||||
|
@@ -172,35 +172,6 @@ QTCREATOR_UTILS_EXPORT QTextStream &operator<<(QTextStream &s, const FilePath &f
|
||||
|
||||
using FilePaths = QList<FilePath>;
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT CommandLine
|
||||
{
|
||||
public:
|
||||
enum RawType { Raw };
|
||||
|
||||
CommandLine();
|
||||
explicit CommandLine(const QString &executable);
|
||||
explicit CommandLine(const FilePath &executable);
|
||||
CommandLine(const QString &exe, const QStringList &args);
|
||||
CommandLine(const FilePath &exe, const QStringList &args);
|
||||
CommandLine(const FilePath &exe, const QString &unparsedArgs, RawType);
|
||||
|
||||
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);
|
||||
|
||||
QString toUserOutput() const;
|
||||
|
||||
FilePath executable() const { return m_executable; }
|
||||
QString arguments() const { return m_arguments; }
|
||||
QStringList splitArguments(OsType osType = HostOsInfo::hostOs()) const;
|
||||
|
||||
private:
|
||||
FilePath m_executable;
|
||||
QString m_arguments;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT FileUtils {
|
||||
public:
|
||||
#ifdef QT_GUI_LIB
|
||||
@@ -402,4 +373,3 @@ template<> struct QTCREATOR_UTILS_EXPORT hash<Utils::FilePath>
|
||||
} // namespace std
|
||||
|
||||
Q_DECLARE_METATYPE(Utils::FilePath)
|
||||
Q_DECLARE_METATYPE(Utils::CommandLine)
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "fileutils.h"
|
||||
#include "processargs.h"
|
||||
#include "commandline.h"
|
||||
#include "qtcassert.h"
|
||||
#include "stringutils.h"
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "stringutils.h"
|
||||
#include "executeondestruction.h"
|
||||
#include "hostosinfo.h"
|
||||
#include "processargs.h"
|
||||
#include "commandline.h"
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "utils_global.h"
|
||||
|
||||
#include "environment.h"
|
||||
#include "processargs.h"
|
||||
#include "commandline.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QTextCodec>
|
||||
|
@@ -34,7 +34,7 @@ SOURCES += \
|
||||
$$PWD/namevalueitem.cpp \
|
||||
$$PWD/namevaluemodel.cpp \
|
||||
$$PWD/namevaluesdialog.cpp \
|
||||
$$PWD/processargs.cpp \
|
||||
$$PWD/commandline.cpp \
|
||||
$$PWD/qrcparser.cpp \
|
||||
$$PWD/qtcprocess.cpp \
|
||||
$$PWD/reloadpromptutils.cpp \
|
||||
@@ -156,7 +156,7 @@ HEADERS += \
|
||||
$$PWD/namevalueitem.h \
|
||||
$$PWD/namevaluemodel.h \
|
||||
$$PWD/namevaluesdialog.h \
|
||||
$$PWD/processargs.h \
|
||||
$$PWD/commandline.h \
|
||||
$$PWD/qrcparser.h \
|
||||
$$PWD/qtcprocess.h \
|
||||
$$PWD/span.h \
|
||||
|
@@ -64,6 +64,8 @@ Project {
|
||||
"classnamevalidatinglineedit.h",
|
||||
"codegeneration.cpp",
|
||||
"codegeneration.h",
|
||||
"commandline.cpp",
|
||||
"commandline.h",
|
||||
"completinglineedit.cpp",
|
||||
"completinglineedit.h",
|
||||
"completingtextedit.cpp",
|
||||
@@ -203,8 +205,6 @@ Project {
|
||||
"porting.h",
|
||||
"portlist.cpp",
|
||||
"portlist.h",
|
||||
"processargs.cpp",
|
||||
"processargs.h",
|
||||
"processhandle.cpp",
|
||||
"processhandle.h",
|
||||
"progressindicator.cpp",
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/infobar.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include <utils/consoleprocess.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/processargs.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/textfileformat.h>
|
||||
#include <utils/unixutils.h>
|
||||
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/processargs.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/variablechooser.h>
|
||||
|
@@ -29,9 +29,8 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QCoreApplication>
|
||||
#include <QJsonObject>
|
||||
#include <QLabel>
|
||||
#include <QPointer>
|
||||
@@ -44,6 +43,7 @@ class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class CommandLine;
|
||||
class FilePath;
|
||||
class PathChooser;
|
||||
class FancyLineEdit;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "versionhelper.h"
|
||||
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/id.h>
|
||||
|
@@ -29,6 +29,10 @@
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
namespace Utils {
|
||||
class CommandLine;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class ProcessParameters;
|
||||
|
||||
|
@@ -33,6 +33,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Utils {
|
||||
class CommandLine;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildConfiguration;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "projectexplorer_export.h"
|
||||
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/commandline.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@@ -86,7 +86,6 @@ extend_qtc_executable(sdktool
|
||||
persistentsettings.cpp persistentsettings.h
|
||||
porting.h
|
||||
qtcassert.cpp qtcassert.h
|
||||
processargs.cpp processargs.h
|
||||
savefile.cpp savefile.h
|
||||
stringutils.cpp stringutils.h
|
||||
)
|
||||
|
@@ -38,7 +38,7 @@ SOURCES += \
|
||||
$$UTILS/namevalueitem.cpp \
|
||||
$$UTILS/persistentsettings.cpp \
|
||||
$$UTILS/qtcassert.cpp \
|
||||
$$UTILS/processargs.cpp \
|
||||
$$UTILS/commandline.cpp \
|
||||
$$UTILS/savefile.cpp \
|
||||
$$UTILS/stringutils.cpp
|
||||
|
||||
@@ -71,7 +71,7 @@ HEADERS += \
|
||||
$$UTILS/namevalueitem.h \
|
||||
$$UTILS/persistentsettings.h \
|
||||
$$UTILS/qtcassert.h \
|
||||
$$UTILS/processargs.h \
|
||||
$$UTILS/commandline.h \
|
||||
$$UTILS/savefile.h \
|
||||
$$UTILS/porting.h
|
||||
|
||||
|
@@ -68,6 +68,7 @@ QtcTool {
|
||||
name: "Utils"
|
||||
prefix: libsDir + "/utils/"
|
||||
files: [
|
||||
"commandline.cpp", "commandline.h",
|
||||
"environment.cpp", "environment.h",
|
||||
"fileutils.cpp", "fileutils.h",
|
||||
"hostosinfo.cpp", "hostosinfo.h",
|
||||
@@ -75,7 +76,6 @@ QtcTool {
|
||||
"namevalueitem.cpp", "namevalueitem.h",
|
||||
"persistentsettings.cpp", "persistentsettings.h",
|
||||
"porting.h",
|
||||
"processargs.cpp", "processargs.h",
|
||||
"qtcassert.cpp", "qtcassert.h",
|
||||
"savefile.cpp", "savefile.h",
|
||||
"stringutils.cpp"
|
||||
|
Reference in New Issue
Block a user