commandlineparser / commandlineparser/commandline
Error parsing with IgnoreUnknownArguments to true and IEnumerable<int> option
- Ngôn ngữ chính
- C#
- Star
- 4.8k
- Fork
- 478
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu tại Parser configuration và ParseArguments bằng cách sử dụng lớp Options được cung cấp, với IgnoreUnknownArguments được bật và IEnumerable cho Seconds. Tái tạo lệnh chứa --test1 xxxx, sau đó xác minh rằng các đối số không xác định được bỏ qua mà không tạo ra BadFormatConversionError hoặc MissingRequiredOptionError cho seconds.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp
- Lĩnh vực
- cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100