commandlineparser / commandlineparser/commandline

Error parsing with IgnoreUnknownArguments to true and IEnumerable<int> option

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

Hi. I am having problems similar to described in #776 but working with version 2.9.1.

My scenario is this:

```csharp
using CommandLine;

namespace QuickStart
{
class Program
{
public class Options
{
[Option('i', "input", Required = true, HelpText = "The name of the videos to split. E.g. media split -i file1.mp4 file2.mp4")]
public IEnumerable Input { get; set; } = new List();

[Option('s', "seconds", Required = true, HelpText = "A space separated list of seconds to split the video. E.g. media split -s 5 10")]
public IEnumerable Seconds { get; set; } = new List();
}

static void Main(string[] args)
{
new Parser(with => { with.IgnoreUnknownArguments = true; })
.ParseArguments(args)
.WithParsed(o =>
{
Console.WriteLine("Quick Start Example!");
})
.WithNotParsed(errors =>
{
foreach (var e in errors)
{
Console.WriteLine($"Error: {e}");
}
});
}
}
}
```

Being IgnoreUnknownArguments = true when I pass more parameters (ex. `--input c:\temp\test.mp4 --seconds 2 4 --test1 xxxx`) it returns

```
Error: CommandLine.BadFormatConversionError
Error: CommandLine.MissingRequiredOptionError (in seconds option)
```

If I change the type of Seconds to `IEnumerable` it works correctly (this is going to be my workaround at this moment) but seems like library continues going crazy trying to parse unknown arguments in this scenario.

Guia de contribuição

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

Direção de pesquisa

Start at Parser configuration and ParseArguments using the provided Options class, with IgnoreUnknownArguments enabled and IEnumerable for Seconds. Reproduce the command containing --test1 xxxx, then verify that the unknown arguments are ignored without producing BadFormatConversionError or MissingRequiredOptionError for seconds.

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
45/100

Receba novas issues na sua caixa de entrada

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