IgnoreUnknownArguments does not work for values
cdmihai opened this issue · 0 comments
cdmihai commented
Given the following snippet where ParserSettings.IgnoreUnknownArguments = false
:
using System;
using CommandLine;
namespace Cmd
{
class Program
{
static void Main(string[] args)
{
var parser = new Parser(with =>
{
with.IgnoreUnknownArguments = false;
with.HelpWriter = Console.Out;
});
var result = parser.ParseArguments<Options>(args);
result.WithParsed(options => Console.WriteLine(options.anInt));
}
}
class Options {
[Option('i', HelpText = "an int")]
public int anInt { get; set; }
}
}
And given the invocation:
app.exe bogus args
I would expect the parser to error out saying it does not understand the unknown arguments bogus args
.
Instead, it does not error out.
Context: I have an optional argument (e.g. -a value
) and I had forgotten to type in the argument name (-a
), I typed in just the value. Instead of having the command line parser fail on encountering value
, it continued working, causing quite a bit of debugging time :)