|
|
|
@ -18,9 +18,20 @@
@@ -18,9 +18,20 @@
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
|
|
using McMaster.Extensions.CommandLineUtils; |
|
|
|
|
|
|
|
|
|
using TomsToolbox.Essentials; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.ILSpy |
|
|
|
|
{ |
|
|
|
|
internal enum InstancingMode |
|
|
|
|
{ |
|
|
|
|
Single, |
|
|
|
|
Multi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sealed class CommandLineArguments |
|
|
|
|
{ |
|
|
|
|
// see /doc/Command Line.txt for details
|
|
|
|
@ -34,32 +45,59 @@ namespace ICSharpCode.ILSpy
@@ -34,32 +45,59 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
|
|
|
|
|
public CommandLineArguments(IEnumerable<string> arguments) |
|
|
|
|
{ |
|
|
|
|
foreach (string arg in arguments) |
|
|
|
|
var app = new CommandLineApplication() { |
|
|
|
|
ResponseFileHandling = ResponseFileHandling.ParseArgsAsSpaceSeparated, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var oInstancing = app.Option("-i|--instancing <single/multi>", "Single or multi instance", CommandOptionType.SingleValue); |
|
|
|
|
var oNavigateTo = app.Option("-n|--navigateto <TYPENAME>", "Navigates to the member specified by the given ID string", CommandOptionType.SingleValue); |
|
|
|
|
var oSearch = app.Option("-s|--search <STRING>", "Search for", CommandOptionType.SingleValue); |
|
|
|
|
var oLanguage = app.Option("-l|--language <STRING>", "Selects the specified language", CommandOptionType.SingleValue); |
|
|
|
|
var oConfig = app.Option("-c|--config <STRING>", "Search for", CommandOptionType.SingleValue); |
|
|
|
|
var oNoActivate = app.Option("--noactivate", "Search for", CommandOptionType.NoValue); |
|
|
|
|
|
|
|
|
|
// https://natemcmaster.github.io/CommandLineUtils/docs/arguments.html#variable-numbers-of-arguments
|
|
|
|
|
// To enable this, MultipleValues must be set to true, and the argument must be the last one specified.
|
|
|
|
|
var files = app.Argument("Assemblies", "Assemblies to load", multipleValues: true); |
|
|
|
|
|
|
|
|
|
app.Parse(arguments.ToArray()); |
|
|
|
|
|
|
|
|
|
if (oInstancing.Value != null) |
|
|
|
|
{ |
|
|
|
|
if (arg.Length == 0) |
|
|
|
|
continue; |
|
|
|
|
if (arg[0] == '/') |
|
|
|
|
if (Enum.TryParse<InstancingMode>(oInstancing.Value(), true, out var mode)) |
|
|
|
|
{ |
|
|
|
|
if (arg.Equals("/singleInstance", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.SingleInstance = true; |
|
|
|
|
else if (arg.Equals("/separate", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.SingleInstance = false; |
|
|
|
|
else if (arg.StartsWith("/navigateTo:", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.NavigateTo = arg.Substring("/navigateTo:".Length); |
|
|
|
|
else if (arg.StartsWith("/search:", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.Search = arg.Substring("/search:".Length); |
|
|
|
|
else if (arg.StartsWith("/language:", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.Language = arg.Substring("/language:".Length); |
|
|
|
|
else if (arg.Equals("/noActivate", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.NoActivate = true; |
|
|
|
|
else if (arg.StartsWith("/config:", StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
this.ConfigFile = arg.Substring("/config:".Length); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
this.AssembliesToLoad.Add(arg); |
|
|
|
|
switch (mode) |
|
|
|
|
{ |
|
|
|
|
case InstancingMode.Single: |
|
|
|
|
SingleInstance = true; |
|
|
|
|
break; |
|
|
|
|
case InstancingMode.Multi: |
|
|
|
|
SingleInstance = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (oNavigateTo.Value != null) |
|
|
|
|
NavigateTo = oNavigateTo.Value(); |
|
|
|
|
|
|
|
|
|
if (oSearch.Value != null) |
|
|
|
|
Search = oSearch.Value(); |
|
|
|
|
|
|
|
|
|
if (oLanguage.Value != null) |
|
|
|
|
Language = oLanguage.Value(); |
|
|
|
|
|
|
|
|
|
if (oConfig.Value != null) |
|
|
|
|
ConfigFile = oConfig.Value(); |
|
|
|
|
|
|
|
|
|
if (oNoActivate.HasValue()) |
|
|
|
|
NoActivate = true; |
|
|
|
|
|
|
|
|
|
foreach (var assembly in files.Values) |
|
|
|
|
{ |
|
|
|
|
if (!string.IsNullOrWhiteSpace(assembly)) |
|
|
|
|
AssembliesToLoad.Add(assembly); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|