Feb 12, 2007

I decidedly need to write documentation for my projects

See this email exchange I had earlier today:

Mono.GetOptions: howto?


FROM: Piercarlo Slavazza

Hi Rafael,

I'm considering usgin Mono.GetOptions for my .net project, and I would
like to know where I can find some documentation or at least some sample
code where to "quickly" figure out how to use the library - of course I
already googled around but I wasn't able to find any good snippets.

Another question: what's license applies to Mono.GetOptions?

Thanks you.
Regards,


FROM: Rafael Teixeira

The last question I'll answer first: the license is BSD/MIT, what
means mainly just use it and be happy.

There is a sample app in the sources (mcat), that show many of
Mono.GetOptions resources.

But It's my fault that little documentation is available.

Some (unfleshed) class documentation is here
http://www.go-mono.com/docs/index.aspx?tlink=0@N%3aMono.GetOptions

Many mono tools also use Mono.GetOptions, but the project that drove
its development is the now defunct mbas (his successor vbnc doesn't
use it).

The main gist is that you do things declaratively. Example:

public class MyOptions : Options {

[Option("Do some important thing", 'i')]
public bool important;

...
}

After calling the option processing in your main method, your instance
of MyOptions, will have 'important' set to true if the command line
have an argument like

/i or /important

Deriving from Options (which isn't mandatory means you already inherit
a help command that generates automatically a help screen with all the
options you've declared.

I'm quite sure the Mono-list archives has some more extensive
explanation I gave some time (years) ago about the subject. Sorry but
I'm in a hurry now.

Thanks for evaluating the use o Mono.GetOptions.

I should point out that I'm starting to work on a better version to be
called Commons.GetOptions, but I now just have the early planning
being cooked (see this blog)

Have fun,
Post a Comment