commandlineparser / commandlineparser/commandline

Make the Error class more useful

Aberta
#183 0 comentários 3 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

Consider the following code:
```cs
parserResult.MapResult(
options => 0,
errs =>
{
foreach (var error in errors)
{
Console.Error(error); //right now this will just print out the Error type
}
return 1;
});
```

Right now building the error string is a manual process of checking the type, casting to the correct subclass, etc. Fortunately that logic already exists here:
https://github.com/commandlineparser/commandline/blob/7aa501d534a657c388f94f66127b4f8dde64ac59/src/CommandLine/Text/SentenceBuilder.cs#L110

All we have to do is put it in `Error.ToString()`...

Another useful addition would be something like `HelpText.AddError(Error)` / `HelpText.AddErrors(Ienumerable)` .

Guia de contribuição

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

Direção de pesquisa

Start with src/CommandLine/Text/SentenceBuilder.cs at the referenced error-formatting logic, then inspect the Error and HelpText classes. Make Error.ToString() expose the existing formatted error text and assess the proposed HelpText.AddError/Error collection helpers; done means errors can be printed usefully without manual type checks.

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
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

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