commandline
commandline copied to clipboard
Sequence - error option is defined multiple times
Wiki - Sequence option states:
Sequence option Sequence options require one or more argument value. its type is: IEnumerable<T> Option name may be repeated more than one time. Thus --files file1.txt file2.txt and --files file1.txt --files file2.txt are equivalent.
In fact, using the second example by specifying the parameter twice leads to an error:
ERROR(S): Option 'input' is defined multiple times.
I'm encountering the same issue with:
class MyOptions
{
[Option('i', "include", ...)]
public IEnumerable<string> IncludePatterns { get; set; }
}
And:
dotnet run -- -i /Work/ -i /Git/
Output:
ERROR(S): Option 'i, include' is defined multiple times.
Do you know if there's any chance to fix this behaviour and the ETA for this?
Have you tried setting the AllowMultiInstance
parser setting to true
? By default it is false
. Without it true, it will cause an error that options can't be repeated, and is even called out as a unit test.
See these links:
- https://github.com/commandlineparser/commandline/blob/1e3607b97af6141743edb3c434c06d5b492f6fb3/src/CommandLine/ParserSettings.cs#L186-L194
- https://github.com/commandlineparser/commandline/blob/1e3607b97af6141743edb3c434c06d5b492f6fb3/tests/CommandLine.Tests/Unit/ParserTests.cs#L975-L1003
I'm guessing that either the documentation should be clarified, or the behavior should be improved around sequence options and the AllowMultiInstance
setting.