commandlineparser / commandlineparser/commandline
Generate Help on a specific verb
- Lenguaje dominante
- C#
- Estrellas
- 4.8k
- Forks
- 478
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
**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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduzca el problema con las clases Verb1 y Verb2 mostradas y, a continuación, siga el resultado desde ParseArguments a través de DisplayHelp, HelpText.AutoBuild y DefaultParsingErrorsHandler. Compruebe cómo se interpretan los argumentos de "help verb1" y cómo verbsIndex afecta a la salida. Se considera terminado cuando solicitar ayuda para un verbo muestra únicamente la ayuda y las opciones de ese verbo, manteniendo el comportamiento existente de ayuda para todos los verbos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100