commandlineparser / commandlineparser/commandline
Generate Help on a specific verb
- 主要语言
- C#
- 星标
- 4.8k
- 派生
- 478
- PR 合并指标
- 30 天内没有已合并 PR
描述
**Describe the bug**
When I call my program with the following arguments : "help verb1", I expect that the help for this specific verb was displayed. But instead, the help for all verbs are displayed.
**To Reproduce**
```
[Verb("Verb1", HelpText ="Help Verb1")]
internal class Verb1
{
[Option(Required = true, HelpText = "Help MyOption1")]
public string MyOption1 { get; set; }
}
[Verb("Verb2",HelpText = "Help Verb2")]
internal class Verb2
{
[Option(Required = true, HelpText = "Help MyOption2")]
public string MyOption2 { get; set; }
}
internal class Program
{
static void Main(string[] args)
{
var parser = new Parser(config => config.HelpWriter = null);
var parserResult = parser.ParseArguments<
Verb1,
Verb2
>
(args);
parserResult.MapResult(
(Verb1 options) => { return 0; },
(Verb2 options) => { return 0; },
errors => {
DisplayHelp(parserResult, errors);
return 0;
});
Console.ReadKey();
}
static void DisplayHelp(ParserResult result, IEnumerable errs)
{
var helpText = HelpText.AutoBuild(result, h =>
{
h.AdditionalNewLineAfterOption = false;
h.Heading = "Myapp 2.0.0-beta"; //change header
h.Copyright = "Copyright (c) 2019 Global.com"; //change copyright text
return HelpText.DefaultParsingErrorsHandler(result, h);
}, e => e, verbsIndex:true);
Console.WriteLine(helpText);
}
}
```
When I excecute this with the command line "MyApp.exe help verb1"
The actual result is :

**Expected behavior**
This display :
Verb2 Help Verb1
MyOption2 Help MyOption2
贡献指南
这个仓库没有索引到贡献指南
调研方向
使用所示的 Verb1 和 Verb2 类复现该问题,然后跟踪结果从 ParseArguments 经过 DisplayHelp、HelpText.AutoBuild 和 DefaultParsingErrorsHandler 的处理过程。检查如何解释 "help verb1" 的参数,以及 verbsIndex 如何影响输出。完成标准是:请求某个 verb 的帮助时,只显示该 verb 的帮助和选项,同时保留现有的所有 verb 帮助行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100