blob: f633518bceedbb10d3ee5d14cdd252e823678074 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#pragma once
#include "moshortcut.h"
#include <vector>
#include <memory>
namespace cl
{
namespace po = boost::program_options;
class Command
{
public:
virtual ~Command() = default;
std::string name() const;
std::string description() const;
po::options_description options() const;
std::string usage() const;
virtual bool allow_unregistered() const;
std::optional<int> run(
const std::wstring& originalLine,
po::variables_map vm,
std::vector<std::wstring> untouched);
protected:
struct Meta
{
std::string name, description;
};
virtual po::options_description doOptions() const;
virtual Meta meta() const = 0;
virtual std::optional<int> doRun() = 0;
const std::wstring& originalCmd() const;
const po::variables_map& vm() const;
const std::vector<std::wstring>& untouched() const;
private:
std::wstring m_original;
po::variables_map m_vm;
std::vector<std::wstring> m_untouched;
};
class CrashDumpCommand : public Command
{
protected:
po::options_description doOptions() const;
Meta meta() const override;
std::optional<int> doRun() override;
};
// this is the `launch` command used when starting a process from within the
// virtualized directory, see processrunner.cpp
//
// it has its own parsing of the command line to extract the argument after
// `launch` and use it as the cwd of the process, but pass the remaining
// arguments verbatim
//
// this is very old code that should probably never be changed
//
// note that it's actually buggy; in particular, it doesn't handle multiple
// whitespace between arguments
//
class LaunchCommand : public Command
{
public:
bool allow_unregistered() const override;
protected:
po::options_description doOptions() const;
Meta meta() const override;
std::optional<int> doRun() override;
int SpawnWaitProcess(LPCWSTR workingDirectory, LPCWSTR commandLine);
LPCWSTR UntouchedCommandLineArguments(
int parseArgCount, std::vector<std::wstring>& parsedArgs);
};
class ExeCommand : public Command
{
public:
bool allow_unregistered() const override;
protected:
po::options_description doOptions() const;
Meta meta() const override;
std::optional<int> doRun() override;
};
class RunCommand : public Command
{
public:
bool allow_unregistered() const override;
protected:
po::options_description doOptions() const;
Meta meta() const override;
std::optional<int> doRun() override;
};
class CommandLine
{
public:
CommandLine();
std::optional<int> run(const std::wstring& line);
void clear();
std::string usage(const Command* c=nullptr) const;
bool multiple() const;
std::optional<QString> profile() const;
std::optional<QString> instance() const;
const MOShortcut& shortcut() const;
std::optional<QString> nxmLink() const;
std::optional<QString> executable() const;
const QStringList& untouched() const;
private:
po::options_description m_visibleOptions, m_allOptions;
po::positional_options_description m_positional;
std::vector<std::unique_ptr<Command>> m_commands;
po::variables_map m_vm;
MOShortcut m_shortcut;
std::optional<QString> m_nxmLink;
std::optional<QString> m_executable;
QStringList m_untouched;
void createOptions();
std::string more() const;
};
} // namespace
|