[Mono-dev] Porting db4o-tool to use Mono.Options rather than Mono.GetOption

Jonathan Pryor jonpryor at vt.edu
Tue Nov 16 23:01:59 EST 2010


On Tue, 2010-11-16 at 18:53 +0000, Paul F. Johnson wrote:
> I'm trying to port it over to use Mono.Options.
...
> My only problem is that I can't see an equivalent of return
> WhatToDoNext.GoAhead; in Mono.Options. Is there such a beastie and if
> there is, what is it called?

That requires knowing what WhatToDoNext.GoAhead does; best I can easily
find is [0], in which case it's used when placing the [Option] attribute
on a method instead of a field/property.  If this is the scenario you're
dealing with, you would just ignore WhatToDoNext.GoAhead, e.g.

        [Mono.GetOptions.Option("warning level",'w',null)]
        public WhatToDoNext SetWarnngLevel(int warningLevel)
        {
          this.WarningLevel=warningLevel;
          return WhatToDoNext.GoAhead;
        }

would translate rather straightforwardly to:

        int warningLevel = 0;
        var o = new OptionSet {
                // ...
                { "w=",
                  "warning level",
                  (int wl) => warningLevel = wl },
        };

Meanwhile, if the method returned WhatToDoNext.AbandonProgram, throwing
an exception with a useful message from the callback would be
appropriate.

 - Jon

[0]
http://jrwren.wrenfam.com/blog/2006/12/04/net-command-line-options-monogetoptions/



More information about the Mono-devel-list mailing list