commandlineparser / commandlineparser/commandline
ParseArguments<T> with only a single TOptions doesnt respect Verb attribute
- Lenguaje dominante
- C#
- Estrellas
- 4.8k
- Forks
- 478
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
When MapResults is presented with only a single Verb-style Options class, the verb is not properly popped off the args stack.
Following code doesnt parse commandline `"myprogram pack MyProjectfile.csproj"`. You end up with `PackOptions.ProjectFile == "pack"` Works fine if additional Options classes with `VerbAttribute` specified.
```c#
public static class Program
{
public static void Main(string[] args)
{
int exitcode = CommandLine.Parser.Default
.ParseArguments(args)
.MapResult(
(PackOptions opts) => 0, //basically do nothing for sample
(parserErrors) => 1
);
}
}
[Verb("pack")]
public class PackOptions
{
[Value(0)]
public string ProjectFile { get; set; }
[Option("outputPath")]
public string OutputPath { get; set; }
}
```
created a dotnetfiddle: https://dotnetfiddle.net/IbwLbX
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.