commandlineparser / commandlineparser/commandline

Settings "EnableDashDash" separator doesn't work properly if last option before "--" is an enumerable option

Abierto
#742 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C#
Estrellas
4.8k
Forks
478
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Tested with version 2.8.0 from NuGet

Example code:
```
using System;
using System.Collections.Generic;
using CommandLine;

class Options
{
[Option("firstOption")]
public bool firstOption { get; set; }

[Option("secondOption", Separator = ',', Required = false)]
public IEnumerable secondOption { get; set; }

[Option("thirdOption", Required = false)]
public string thirdOption { get; set; }

[Value(0)]
public IEnumerable additional {get; set; }
}

public class Program
{
public static void Main()
{
var arguments = "--firstOption --secondOption=\"first,second,third\" -- addfirst addsecond -addthird";
//var arguments = "--firstOption --secondOption=\"first,second,third\" --thirdOption=blabla -- addfirst addsecond -addthird";
Console.WriteLine($"Command => {arguments}");
var args = arguments.Split();
Init(args);
}

public static void Init(string[] args)
{
var p = new Parser(with => with.EnableDashDash = true);
var result = p.ParseArguments(args).WithParsed(options =>{
Console.WriteLine($"firstOption: {options.firstOption}");
var joined = string.Join(",", options.secondOption);
Console.WriteLine($"secondOption: {joined}");
joined = string.Join(",", options.additional);
Console.WriteLine($"additional: {joined}");
} ).WithNotParsed (e=>e.Dump());
}
}
```
If the code is ran with the first version of the arguments the following output results, which is not the expected behavior:
```
Command => --firstOption --secondOption="first,second,third" -- addfirst addsecond -addthird
firstOption: True
secondOption: "first,second,third",addfirst,addsecond,-addthird
additional:
```
if we add another option between the "--" end of options "separator" we have the expected behavior:
```
Command => --firstOption --secondOption="first,second,third" --thirdOption=blabla -- addfirst addsecond -addthird
firstOption: True
secondOption: "first,second,third"
additional: addfirst,addsecond,-addthird
```

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.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.