c# - Get invalid parameters from commandline parser -
i use commandline parser nuget.
var options = new options(); bool isinputvalid = commandline.parser.default.parsearguments(args, options);
how parameters invalid?
in 1.9.71
dont' see option can fetch invalid tokens arguments after parsing. if upgrade -pre release version i.e.
<package id="commandlineparser" version="2.0.275-beta" targetframework="net45" />
this version gives flexibility more parsed results. can find invalid token below:
var result = commandline.parser.default.parsearguments<options>(args); result.mapresult( options => { // optios return 0; }, errors => { var invalidtokens = errors.where(x => x tokenerror).tolist(); if(invalidtokens != null) { invalidtokens.foreach(token => console.writeline(((tokenerror)token).token)); } return 1; });
Comments
Post a Comment