When MapResults is presented with only a single Verb-style Options class, the verb is not properly popped off the args stack.
Following code doesnt parse commandline "myprogram pack MyProjectfile.csproj". You end up with PackOptions.ProjectFile == "pack" Works fine if additional Options classes with VerbAttribute specified.
```c#
public static class Program
{
public static void Main(string[] args)
{
int exitcode = CommandLine.Parser.Default
.ParseArguments
.MapResult(
(PackOptions opts) => 0, //basically do nothing for sample
(parserErrors) => 1
);
}
}
[Verb("pack")]
public class PackOptions
{
[Value(0)]
public string ProjectFile { get; set; }
[Option("outputPath")]
public string OutputPath { get; set; }
}
```
created a dotnetfiddle: https://dotnetfiddle.net/IbwLbX
Duplicate of #65
I also stumbled on the issue (as I only have 1 verb currently) and worked around the issue by passing object as second verb type - this forces the library to use the correct extension method:
return Parser.Default
.ParseArguments<ExportOptions, object>(args)
.MapResult(
(ExportOptions opts) => 0,
errs => 1);
@kvalev ,Good Trick
@ericnewton76 ,I modified your demo using object as second verb type and give the same result.
Modified demo
Most helpful comment
I also stumbled on the issue (as I only have 1 verb currently) and worked around the issue by passing
objectas second verb type - this forces the library to use the correct extension method: