"Separator" option for OptionList doesn't works for me

Dec 4, 2009 at 6:12 PM

Hello, I am using version of this lib and I am getting troubles using the OptionList attribute.

In facts, i write this code:

[Option("i", "input", Required = true, Separator = ',', HelpText = "Input file to read.")]
public List<string> InputFiles = null;

but the compiler says: 'CommandLine.OptionAttribute' doesn't contains a definition for 'Separator'

how can I solve this?




Dec 5, 2009 at 12:06 AM

Dear User,

thank you for your interest in this project.

The problem here is that you're not using the correct option attribute. You're using Option as it were OptionList. Try the following:

[OptionList("i", "input", Required = true, Separator = ',', HelpText = "Input file to read.")]
public IList<string> InputFiles = null;

I also suggest you to declare the field as IList<string> and not List<string>.

You can read about OptionList here: Documentation / User Guide / Attributes Define Your Syntax / Option List Attribute.



Dec 5, 2009 at 4:00 PM

Thanks for your help. I was sure i have copy/pasted the example code :D Strange things happens..



Dec 7, 2009 at 4:24 PM

Dear FBSC,

is a pleasure for me to give a hand to those who are interested in this project.

I want to give you more info to make a the more possible correct design choice in your application.

As said in this discussion, every one interested in OptionList should consider OptionArray.

Another feature that lets you collect multiple values is ValueList, take a look. I suggest you to use it in combination with an Option that targets a boolean field (and/or mutually exclusive options).