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
贡献指南
这个仓库没有索引到贡献指南
调研方向
Start at Parser.ParseArguments(args) and its MapResult overload, then trace VerbAttribute handling for the single-options case. Reproduce the command from the issue or the linked .NET Fiddle; done means "pack" is consumed as the verb and ProjectFile receives "MyProjectfile.csproj", with existing multi-verb behavior preserved.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100