[Mono-dev] Lazy man´s Command Line Parser - Revisited
oforero at novell.com
Thu Jan 12 05:54:50 EST 2006
I discussed on IRC some points over my parser in the mono channel; more or less seems that the people do not want to
know anything about it; and that many are happy with Mono.GetOptions.
I still think mine is a superior solution, simple because it does a lot more that Mono.GetOptions; some of the negative
comments and my answers to them:
1. Is not intuitive: Well following a naming convention and/or using Attributes is pretty easy, and should be at least
as easy as extending a class.
2. It takes a lot of reading to know which parameters are supported: Well not really, if you want to know how to use a
program, let it run with out command line and the help will tell you how it work, if you want to know which parameters
are supported by a given operation go to the method. It is that easy, now i agree you can have a quicker overview over
all the parameters in the application with Mono.GetOptions, but if you need to know which parameters are use in a given
operation you have to read yourself through a lot of If s see what method is being call, go there and read some more.
3. It is not maintainable, if you need to add a parameter (the same) to many operations you need to go to every method
and add it by hand: Well that is actually a problem, but i already have a solution for that, and is call
ExpandableParameters, you can use any class with public fields an default public constructor as a method parameter, if
you mark the method parameter as [Expandable] it will use that class to add more parameters to the operation, and you
will get an instance of the object with the fields properly filled. Now i know that public fields are not really the
best way to do it, but it was the fastest way to probe the concept. I will like to know if there is any interest in
having support for properties instead of fields.
I think this last addition solved the biggest name problem with it, in that way you can have a centralized object where
the parameters are, with the advantage that you can have different classes grouping parameters, not only one. And is
still possible to get the command dispatching saving you having to write all that if chains, and using control
Take a look on the OnExample method of the example code.
PS: Next add is support for serialized objects as parameters.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 49056 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060112/a2107b88/attachment.obj
More information about the Mono-devel-list