commandlineparser / commandlineparser/commandline
Method for Assembling Custom Help Info
- Ngôn ngữ chính
- C#
- Star
- 4.8k
- Fork
- 478
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
# Problem
The `HelpText` displays the Package Id. I would like to replace that with the Product name and the Description.
# Investigation
I looked through the source code and found this was being done inside the `HelpText.AutoBuild` method, but this method is deep in a chain of abstraction. I could be missing something, but it seemed difficult to extract it to build a custom build method.
# Proposal
I understand this is a lot of changes to how things work and I don't have the experience of what all the pieces of source code are doing, but this is my rough whiteboard level idea of a solution.
## Add HelpText to ParserSettings
This `HelpText` object would allow users to set their own `HelpText` object to be used by the `DisplayHelp` method. Creating default fallbacks seems common in this library, so a similar technique can be used here. If the `ParserSettings` provides a `HelpText` instance, use that, otherwise create and use a default.
## Create Action HelpText.Build
The `HelpText.Build` method would be used by `HelpText.AutoBuild` to generate the output of the help. It can accept options such as `verbsIndex` and `maxDisplayWidth`. This method can then be defined to create custom display behavior.
The following pseudocode illustrates my intentions for this method:
```C#
// HelpText
public static something AutoBuild(HelpText) {
if(HelpText) {
// Do setup.
HelpText.Build();
}
}
// Somewhere else.
HelpText.Build = (options) => {
// Do string building.
}
```
Things like the verb list could be passed in as arguments to the delegate to simplify things.
```C#
(verbs) => {
if(verbs != null) {
foreach(var verb in verbs) {
builder.Add(" {0}", verb);
}
}
}
```
# Conclusion
I think this method could be made backwards compatible and would offer a straight forward way to format help text in a completely custom way while still getting to utilize the auto detection of the help verb and the --help option.
Thanks
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách lần theo HelpText.AutoBuild qua DisplayHelp và kiểm tra cách ParserSettings được sử dụng. So sánh các điểm vào HelpText và Build tùy chỉnh của đề xuất với chuỗi abstraction hiện có. Hoàn tất khi người dùng có thể cung cấp định dạng trợ giúp tùy chỉnh trong khi hành vi trợ giúp tự động hiện tại vẫn giữ được khả năng tương thích ngược.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp
- Lĩnh vực
- cli
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 30/100