commandlineparser / commandlineparser/commandline
DashDash (--) doesn't work properly with multi-value options
- Linguagem predominante
- C#
- Estrelas
- 4.8k
- Forks
- 478
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
When using the "DashDash" feature, the results are unexpected when using a multi-valued option.
## Single-valued option (base case)
`Program.cs`
```C#
class Program
{
#region Main
static int Main(string[] args)
{
return new Parser(with => with.EnableDashDash = true)
.ParseArguments(args)
.MapResult(options => RunWrappedExecutable(options),
_ => -2);
}
#endregion
}
```
`CommandLineOptions.cs`
```C#
class CommandLineOptions
{
#region Properties
[Option('o', "option")]
public string Option { get; set; }
[Value(0)]
public IEnumerable Values { get; set; }
#endregion
}
```
Running the program as follows:
```
foo.exe -o "option" -- value1 value2 value3
```
produces the (expected) results:
```
options.Option = "option"
options.Values = [ "value1", "value2", "value3" ]
```
## Multi-valued option (broken case)
`CommandLineOptions.cs`
```C#
class CommandLineOptions
{
#region Properties
[Option('o', "option")]
public IEnumerable Option { get; set; }
[Value(0)]
public IEnumerable Values { get; set; }
#endregion
}
```
Running the program as follows:
```
foo.exe -o "option" -- value1 value2 value3
```
produces the (unexpected) results:
```
options.Option = [ "option", "value1", "value2", "value3" ]
options.Values = [ ]
```
## Conclusion
My expectation is that any arguments after the `--` would be processed as values, rather than options. Can you confirm my expectations match yours? If so, I'm happy to try to resolve this issue and submit a PR. Thanks!
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Reproduza o comando mostrado em Program.cs usando a opção de múltiplos valores em CommandLineOptions.cs, com EnableDashDash habilitado. Rastreie o ponto de entrada do parser que trata o separador -- e compare os casos de valor único e IEnumerable. Considera-se concluído quando os argumentos após -- preenchem Values, enquanto a opção retém apenas o valor que a precede, com um teste de regressão cobrindo o exemplo.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp
- Domínio
- cli
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100