how to use OptionList...

Nov 5, 2009 at 5:05 PM

Hello I am having trouble getting OptionList to work.


I want the following


this is what i have on my type:


            public IList<string> Gateways = null;


public IList<string> Gateways = null;


Any thoughts?


Nov 6, 2009 at 4:43 PM

Dear user,

you're having problems for two reason:

  1. you are using the same name for short and long option (and this may be a little confusing...)
  2. in your invocation example you use a single dash (again, single dash are for short option or for short options group [*1]) and you leave a space after separator (,) character

Without changing the code the correct command line invocation is:

yourapp --mbg,

(If you enclose the value between quotes still using the space - like this "," - the second item will start with a space ' '.)

I could suggest you two solutions.

A) Don't the define the short option name:

[OptionList(null, "mbg", Separator = ',')]

in this way your app will accept the input suggested above.

B) Define a correct (again, read [*1]) short option of only 1 character (you could also suggest in your help screen to enclose the argument in double quotes):

[OptionList("m", "mbg", Separator = ',')]

doing in this way and calling String.Trim() for each element of IList<string> you could allow an input like this

yourapp -m ","

that is more similar to what you intended to get.


[*1] Actually short option name with more than more character are allowed, but as you can see, this can be cause of problems. The next version will solve this issue. For now use short options of one character or set the property to null.




Nov 15, 2009 at 12:10 PM

Dear user,

version beta (or higher, available in source code control repository)

forces to define short name to null or to a one character string.

Thank again,


P.S.: If anyone thinks that things should work differently, please post a reply or open an issue on issue tracker.

Nov 28, 2009 at 12:28 PM

Dear user (and everyone interested),

please consider the use of OptionArray[Attribute]. This feature (still not present in a version marked stable or rc) is available from version branch 1.7+ (at the moment the more stable is beta).

Please read:

More on OptionList[Attribute]: