Is there a way to make the Parser library for the command line report unknown arguments?
Given the following class parameters:
public class Options { [Option('i', "int-option", DefaultValue = 10, HelpText = "Set the int")] public int IntOption { get; set; } [ParserState] public IParserState LastParserState { get; set; } [HelpOption] public string GetUsage() { return HelpText.AutoBuild(this, HelpText.DefaultParsingErrorsHandler(this, current)); } }
And the following program:
var options = new Options(); var parser = new Parser(settings => { settings.HelpWriter = Console.Error; settings.IgnoreUnknownArguments = false; }); if (parser.ParseArgumentsStrict(args, options)) { Console.WriteLine("Int value set: {0}", options.IntOption); }
When I call the program with "MyProgram.exe --unknown", I just get the default usage information, but donβt mention which error caused the parsing to fail. I would like to get some indication to the user what went wrong.
source share