Browse Source

Enable help option (going with https://blog.rsuter.com/write-application-can-act-console-application-wpf-gui-application/ to display help leads to a flickering console window)

pull/3205/head
Christoph Wille 2 years ago
parent
commit
1fc9f92917
  1. 7
      ILSpy.Tests/CommandLineArgumentsTests.cs
  2. 8
      ILSpy/CommandLineArguments.cs

7
ILSpy.Tests/CommandLineArgumentsTests.cs

@ -23,6 +23,13 @@ namespace ICSharpCode.ILSpy.Tests
cmdLineArgs.ConfigFile.Should().BeNull(); cmdLineArgs.ConfigFile.Should().BeNull();
} }
[Test]
public void VerifyHelpOption()
{
var cmdLineArgs = new CommandLineArguments(new string[] { "--help" });
cmdLineArgs.ArgumentsParser.IsShowingInformation.Should().BeTrue();
}
[Test] [Test]
public void VerifyForceNewInstanceOption() public void VerifyForceNewInstanceOption()
{ {

8
ILSpy/CommandLineArguments.cs

@ -23,7 +23,7 @@ using System.Linq;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
sealed class CommandLineArguments public sealed class CommandLineArguments
{ {
// see /doc/Command Line.txt for details // see /doc/Command Line.txt for details
public List<string> AssembliesToLoad = new List<string>(); public List<string> AssembliesToLoad = new List<string>();
@ -34,6 +34,8 @@ namespace ICSharpCode.ILSpy
public bool NoActivate; public bool NoActivate;
public string ConfigFile; public string ConfigFile;
public CommandLineApplication ArgumentsParser { get; }
public CommandLineArguments(IEnumerable<string> arguments) public CommandLineArguments(IEnumerable<string> arguments)
{ {
var app = new CommandLineApplication() { var app = new CommandLineApplication() {
@ -44,6 +46,9 @@ namespace ICSharpCode.ILSpy
// UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.CollectAndContinue // UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.CollectAndContinue
}; };
app.HelpOption();
ArgumentsParser = app;
var oForceNewInstance = app.Option("--newinstance", var oForceNewInstance = app.Option("--newinstance",
"Start a new instance of ILSpy even if the user configuration is set to single-instance", "Start a new instance of ILSpy even if the user configuration is set to single-instance",
CommandOptionType.NoValue); CommandOptionType.NoValue);
@ -76,7 +81,6 @@ namespace ICSharpCode.ILSpy
// To enable this, MultipleValues must be set to true, and the argument must be the last one specified. // 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); var files = app.Argument("Assemblies", "Assemblies to load", multipleValues: true);
// string helptext = app.GetHelpText();
app.Parse(arguments.ToArray()); app.Parse(arguments.ToArray());
if (oForceNewInstance.HasValue()) if (oForceNewInstance.HasValue())

Loading…
Cancel
Save