commandlineparser / commandlineparser/commandline

Method for Assembling Custom Help Info

Aberta
#446 2 comentários 2 reações 0 responsáveis Ver no GitHub
Linguagem predominante
C#
Estrelas
4.8k
Forks
478
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

# 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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Start by tracing HelpText.AutoBuild through DisplayHelp and inspect how ParserSettings is used. Compare the proposal's custom HelpText and Build entry points with the existing abstraction chain. Done means users can provide custom help formatting while existing automatic help behavior remains backward compatible.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp
Domínio
cli
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
30/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.