-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example with Option with IEnumerable<string> broken - Sequence contains more than one element #377
Comments
Actually, this was an issue instead with Parsing a Dict Is this supported? |
No, unfortunately dicts are not supported |
A dictionary would be hard to support... what generates the keys for the values? I would believe this is undefined in the getopt specs that this library strives to follow. |
I think you are correct Eric that it would be hard to support. I think this is more about protecting against dumb new user and a clearer exception behavior than implementing support :). As a C# dev, Dictionary is popular and for better or worse, it's what I expected/hoped to use here as one of the cmd line options. The above is actually misleading, as I thought the IEnumerable is what was causing the issue, but instead the Dict used as another possible cmd-line parameter (turns out didn't need it) My suggestion is the user adds odd or not supported stuff, that we have a clearer exception than |
Indeed. The error is misleading. |
Hi everyone, I see that this issue has been open for a few years now, I'd like to make a recap and see this issue closed. First of all, I noticed that the example code reported in the first message contains an error because
If we try to parse the following options, the library correctly throws a
As @ivberg-zz and @eric pointed out later, this issue is actually about improving the error message when the developed tries to use an unsupported type (i.e. a dictionary). I noticed that the user @phaniva made a pull request phaniva:issue-377 with a proposed solution of adding a new specification guard that ensures that all sequence type require exactly one argument.
The problem with this solution is that the error In my opinion there are two possible solutions to the problem:
Is it fair to have some checks inside the Thanks in advance and kind regards, |
Running the latest commandlineparser v2.3.0 on .Net Core 2.1.
The library example doesn't seem to work at all parsing IEnumerable
[Option('r', "read", Required = true, HelpText = "Input files to be processed.")]
public IEnumerable InputFiles { get; set; }
If you specify --read file1 file2 you get this exception:
System.InvalidOperationException
HResult=0x80131509
Message=Sequence contains more than one element
Source=System.Linq
StackTrace:
The text was updated successfully, but these errors were encountered: