Generate Help on a specific verb
還沒有人認領這個 Issue。
評估
研究方向
使用所示的 Verb1 和 Verb2 類別重現此問題,然後追蹤結果從 ParseArguments 經過 DisplayHelp、HelpText.AutoBuild 和 DefaultParsingErrorsHandler 的處理流程。檢查如何解讀 "help verb1" 的引數,以及 verbsIndex 如何影響輸出。完成標準是:要求某個 verb 的說明時,只顯示該 verb 的說明和選項,同時保留現有的所有 verb 說明行為。
由索引模型根據 Issue 內容生成。
描述
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<T>(ParserResult<T> result, IEnumerable<Error> 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
- 主要語言
- C#
- 星號
- 4.8k
- 分支
- 479
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
commandlineparser/commandline 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
commandlineparser/commandline#951 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 70/100
commandlineparser/commandline#880 · 2 個 reaction ·
-
難度 5/5 一週以上 新手友好度 45/100
commandlineparser/commandline#952 ·
-
難度 3/5 1-2 天 新手友好度 35/100
commandlineparser/commandline#948 ·
-
難度 5/5 一週以上 新手友好度 35/100
commandlineparser/commandline#947 ·
查看 commandlineparser/commandline 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 80/100
維護者通常 1 天內回覆
-
:watch: Not Triaged aspnet-core/svc fundamentals/subsvc Source - Docs.ms
難度 1/5 1 小時以內 新手友好度 85/100
dotnet/AspNetCore.Docs#37785 ·
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 66/100
Azure/azure-sdk-tools#17204 ·
維護者通常 1 天內回覆
-
area-tutorials needs-triage
難度 2/5 1-3 小時 新手友好度 75/100
dotnet/website-feedback#1779 ·