commandlineparser / commandlineparser/commandline
ParseArguments<T> with only a single TOptions doesnt respect Verb attribute
- 主要言語
- C#
- スター
- 4.8k
- フォーク
- 478
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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(args)
.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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。