-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathArguments.cs
More file actions
438 lines (376 loc) · 11.9 KB
/
Arguments.cs
File metadata and controls
438 lines (376 loc) · 11.9 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Microsoft.DotNet.XHarness.iOS.Shared.Hardware;
namespace Microsoft.DotNet.XHarness.iOS.Shared.Execution;
/// <summary>
/// Specify the location of Apple SDKs, default to 'xcode-select' value.
/// </summary>
public sealed class SdkRootArgument : SingleValueArgument
{
public SdkRootArgument(string sdkPath) : base("sdkroot", sdkPath, false)
{
}
}
/// <summary>
/// List the currently connected devices and their UDIDs.
/// </summary>
public sealed class ListDevicesArgument : SingleValueArgument
{
public ListDevicesArgument(string outputFile) : base("listdev", outputFile)
{
}
}
/// <summary>
/// When listing devices, should mlaunch also scan for wireless devices.
/// </summary>
public sealed class ListWirelessDevicesArgument : SingleValueArgument
{
public ListWirelessDevicesArgument(bool wirelessEnabled) : base("list-wireless-devices", wirelessEnabled ? "true" : "false", true)
{
}
}
/// <summary>
/// Write the syslog from the device to the console.
/// </summary>
public sealed class LogDevArgument : OptionArgument
{
public LogDevArgument() : base("logdev")
{
}
}
/// <summary>
/// List the available simulators. The output is xml, and written to the specified file.
/// </summary>
public sealed class ListSimulatorsArgument : SingleValueArgument
{
public ListSimulatorsArgument(string outputFile) : base("listsim", outputFile)
{
}
}
/// <summary>
/// Lists crash reports on the specified device
/// </summary>
public sealed class ListCrashReportsArgument : SingleValueArgument
{
public ListCrashReportsArgument(string outputFile) : base("list-crash-reports", outputFile)
{
}
}
/// <summary>
/// Specifies the device type to launch the simulator as.
/// </summary>
public sealed class DeviceArgument : SingleValueArgument
{
public DeviceArgument(string deviceType) : base("device", deviceType)
{
}
}
/// <summary>
/// Specify which device (when many are present) the [install|lauch|kill|log]dev command applies.
/// </summary>
public sealed class DeviceNameArgument : SingleValueArgument
{
private const string ArgName = "devname";
public DeviceNameArgument(string deviceName) : base(ArgName, deviceName, false)
{
}
public DeviceNameArgument(IDevice device) : base(ArgName, device.UDID, false)
{
}
}
/// <summary>
/// Install the specified iOS app bundle on the device.
/// </summary>
public sealed class InstallAppOnDeviceArgument : SingleValueArgument
{
public InstallAppOnDeviceArgument(string appPath) : base("installdev", appPath, false)
{
}
}
/// <summary>
/// Install the specified iOS app bundle on the Simulator.
/// </summary>
public sealed class InstallAppOnSimulatorArgument : SingleValueArgument
{
public InstallAppOnSimulatorArgument(string appPath) : base("installsim", appPath, false)
{
}
}
/// <summary>
/// Uninstall the specified bundle id from the device.
/// </summary>
public sealed class UninstallAppFromDeviceArgument : SingleValueArgument
{
public UninstallAppFromDeviceArgument(string appBundleId) : base("uninstalldevbundleid", appBundleId, false)
{
}
}
/// <summary>
/// Specify the output format for some commands as Default.
/// </summary>
public sealed class DefaultOutputFormatArgument : SingleValueArgument
{
public DefaultOutputFormatArgument() : base("output-format", "Default")
{
}
}
/// <summary>
/// Specify the output format for some commands as XML.
/// </summary>
public sealed class XmlOutputFormatArgument : SingleValueArgument
{
public XmlOutputFormatArgument() : base("output-format", "XML")
{
}
}
/// <summary>
/// Download a crash report from the specified device.
/// </summary>
public sealed class DownloadCrashReportArgument : SingleValueArgument
{
public DownloadCrashReportArgument(string deviceName) : base("download-crash-report", deviceName)
{
}
}
/// <summary>
/// Specifies the file to save the downloaded crash report.
/// </summary>
public sealed class DownloadCrashReportToArgument : SingleValueArgument
{
public DownloadCrashReportToArgument(string outputFile) : base("download-crash-report-to", outputFile)
{
}
}
/// <summary>
/// Include additional data (which can take some time to fetch) when listing the connected devices.
/// Only applicable when output format is xml.
/// </summary>
public sealed class ListExtraDataArgument : OptionArgument
{
public ListExtraDataArgument() : base("list-extra-data")
{
}
}
/// <summary>
/// Attach native debugger.
/// </summary>
public sealed class AttachNativeDebuggerArgument : OptionArgument
{
public AttachNativeDebuggerArgument() : base("attach-native-debugger")
{
}
}
/// <summary>
/// Attempt to disable memory limits for launched apps.
/// This is just an attempt, some or all usual limits may still be enforced.
/// </summary>
public sealed class DisableMemoryLimitsArgument : OptionArgument
{
public DisableMemoryLimitsArgument() : base("disable-memory-limits")
{
}
}
public sealed class WaitForExitArgument : OptionArgument
{
public WaitForExitArgument() : base("wait-for-exit")
{
}
}
/// <summary>
/// Launch the app with this command line argument. This must be specified multiple times for multiple arguments.
/// </summary>
public sealed class SetAppArgumentArgument : MlaunchArgument
{
private readonly string _value;
public SetAppArgumentArgument(string value, bool isAppArg = false)
{
_value = value ?? throw new ArgumentNullException(nameof(value));
if (isAppArg)
{
_value = "-app-arg:" + _value;
}
}
public override string AsCommandLineArgument() => "-argument=" + _value;
}
/// <summary>
/// Set the environment variable in the application on startup.
/// </summary>
public sealed class SetEnvVariableArgument : MlaunchArgument
{
private readonly string _variableName;
private readonly string _variableValue;
public SetEnvVariableArgument(string variableName, object variableValue)
{
_variableName = variableName ?? throw new ArgumentNullException(nameof(variableName));
if (variableValue is bool b)
{
_variableValue = b.ToString().ToLowerInvariant();
}
else
{
_variableValue = variableValue?.ToString() ?? throw new ArgumentNullException(nameof(variableValue));
}
}
public override string AsCommandLineArgument() => Escape($"-setenv={_variableName}={_variableValue}");
}
/// <summary>
/// Redirect the standard output for the simulated application to the specified file.
/// </summary>
public sealed class SetStdoutArgument : SingleValueArgument
{
public SetStdoutArgument(string targetFile) : base("stdout", targetFile)
{
}
}
/// <summary>
/// Redirect the standard error for the simulated application to the specified file.
/// </summary>
public sealed class SetStderrArgument : SingleValueArgument
{
public SetStderrArgument(string targetFile) : base("stderr", targetFile)
{
}
}
/// <summary>
/// Launch an app that is installed on device, specified by bundle identifier.
/// </summary>
public sealed class LaunchDeviceArgument : SingleValueArgument
{
private const string ArgName = "launchdev";
public LaunchDeviceArgument(string launchAppPath) : base(ArgName, launchAppPath, false)
{
}
public LaunchDeviceArgument(AppBundleInformation appInfo) : base(ArgName, appInfo.AppPath, false)
{
}
}
/// <summary>
/// Launch an app that is installed on device,
/// </summary>
public sealed class LaunchDeviceBundleIdArgument : SingleValueArgument
{
private const string ArgName = "launchdevbundleid";
public LaunchDeviceBundleIdArgument(string bundleId) : base(ArgName, bundleId, false)
{
}
public LaunchDeviceBundleIdArgument(AppBundleInformation appInfo) : base(ArgName, appInfo.BundleIdentifier, false)
{
}
}
/// <summary>
/// Launch the specified app in the simulator.
/// </summary>
public sealed class LaunchSimulatorAppArgument : SingleValueArgument
{
private const string ArgName = "launchsim";
public LaunchSimulatorAppArgument(string launchAppPath) : base(ArgName, launchAppPath, false)
{
}
public LaunchSimulatorAppArgument(AppBundleInformation appInfo) : base(ArgName, appInfo.AppPath, false)
{
}
}
/// <summary>
/// Launch the simulator only.
/// </summary>
public sealed class LaunchSimulatorArgument : OptionArgument
{
private const string ArgName = "launchsimulator";
public LaunchSimulatorArgument() : base(ArgName)
{
}
}
/// <summary>
/// Launch the specified already installed app in the simulator.
/// </summary>
public sealed class LaunchSimulatorBundleArgument : SingleValueArgument
{
public LaunchSimulatorBundleArgument(AppBundleInformation appInfo) : base("launchsimbundleid", appInfo.BundleIdentifier, true)
{
}
}
/// <summary>
/// Specify which simulator to launch.
/// </summary>
public sealed class SimulatorUDIDArgument : MlaunchArgument
{
private readonly string _udid;
public SimulatorUDIDArgument(string udid)
{
_udid = udid ?? throw new ArgumentNullException(nameof(udid));
}
public SimulatorUDIDArgument(IDevice device)
{
_udid = device?.UDID ?? throw new ArgumentNullException(nameof(device));
}
public override string AsCommandLineArgument() => $"--device=:v2:udid={_udid}";
}
/// <summary>
/// Launch an app that is installed on device, specified by bundle identifier.
/// </summary>
public sealed class LaunchSimulatorExtensionArgument : MlaunchArgument
{
private readonly string _launchAppPath;
private readonly string _bundleId;
public LaunchSimulatorExtensionArgument(string launchAppPath, string bundleId)
{
_launchAppPath = launchAppPath ?? throw new ArgumentNullException(nameof(launchAppPath));
_bundleId = bundleId ?? throw new ArgumentNullException(nameof(bundleId));
}
public override string AsCommandLineArgument() => "--launchsimbundleid " +
"todayviewforextensions:" + Escape(_bundleId) + " " +
"--observe-extension " + Escape(_launchAppPath);
}
/// <summary>
/// Launch the specified bundle id in the simulator (which must already be installed).
/// </summary>
public sealed class LaunchDeviceExtensionArgument : MlaunchArgument
{
private readonly string _launchAppPath;
private readonly string _bundleId;
public LaunchDeviceExtensionArgument(string launchAppPath, string bundleId)
{
_launchAppPath = launchAppPath ?? throw new ArgumentNullException(nameof(launchAppPath));
_bundleId = bundleId ?? throw new ArgumentNullException(nameof(bundleId));
}
public override string AsCommandLineArgument() => "--launchdevbundleid " +
"todayviewforextensions:" + Escape(_bundleId) + " " +
"--observe-extension " + Escape(_launchAppPath);
}
/// <summary>
/// Set the verbosity level. Can be used repeatedly to lower the level.
/// </summary>
public sealed class VerbosityArgument : MlaunchArgument
{
public VerbosityArgument()
{
}
public override string AsCommandLineArgument() => "-v";
}
/// <summary>
/// Create a tcp tunnel with the iOS device from the host.
/// </summary>
public sealed class TcpTunnelArgument : MlaunchArgument
{
private readonly int _port;
public TcpTunnelArgument(int port)
{
if (port <= 0)
{
throw new ArgumentOutOfRangeException(nameof(port));
}
_port = port;
}
public override string AsCommandLineArgument() => $"--tcp-tunnel={_port}:{_port}";
}
/// <summary>
/// Specify a timeout (in seconds) for the commands that doesn't have fixed duration.
/// </summary>
public sealed class TimeoutArgument : SingleValueArgument
{
public TimeoutArgument(double timeoutInSeconds) : base("timeout", timeoutInSeconds.ToString())
{
}
}