← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] merge

 

On Mon, May 11, 2009 at 08:33:42AM +0200, Johan Hake wrote:
> On Monday 11 May 2009 08:09:42 Anders Logg wrote:
> > On Mon, May 11, 2009 at 07:44:29AM +0200, Johan Hake wrote:
> > > On Sunday 10 May 2009 23:47:47 Anders Logg wrote:
> > > > On Sun, May 10, 2009 at 11:42:50PM +0200, DOLFIN wrote:
> > > > > changeset:   6120:76bf86cf514eb0dbc88861c3ae3e6f113a80141a
> > > > > parent:      6117:84edb07b28286a6ca33c399ad30d32b634b52ea9
> > > > > user:        Anders Logg <logg@xxxxxxxxx>
> > > > > date:        Sun May 10 23:40:32 2009 +0200
> > > > > files:       dolfin/parameter/NewParameter.cpp
> > > > > dolfin/parameter/NewParameter.h dolfin/parameter/NewParameters.cpp
> > > > > dolfin/parameter/NewParameters.h sandbox/misc/cpp/main.cpp
> > > > > description: Implement parsing of command-line options using
> > > > > boost::program_options
> > > >
> > > > This seems to work nicely and didn't require that much
> > > > code. Parameters can now be read from the command line with
> > >
> > > Works fine. How do we set the nested parameters?
> >
> > Don't know yet. There is some support for it in po but I haven't
> > figured it out yet.
> 
> I think you can implement this by adding the nested parameters with a 
> recursive function, which takes a "name base" as optional argument. In meta 
> code.
> 
>   def register_options(parameters,base=""): 
>       for params in parameters:
>           if params is NewParameter:
>               add_option(base+params.name())
>           elif isinstance(params,NewParameters):
>               register_options(base+"-"+params.name)
> 
> Here "-" is the deliminator, could be "." too.

This looks like Python. What I need to know is the C++ code for doing
this with boost::program_options. :-)

> The parsing could be done in a similare way.
> 
> > > Does po comes with some help functionality, so
> > >
> > >   ./test --help
> > >
> > > can print the available options?
> >
> > Yes, I've just added this.
> >
> > But I'm not sure what to do when this option is given. Right now, the
> > help text is printed but the program does not exit. Suggestions?
> 
> I think the program should exit. But with which exit code I am not sure, 
> probably 0.

The problem is where to make the exit call. It's simple to enough to
add this inside the parameter parser, but that might mess things up
outside (not a clean exit). Anyway, I'll add this for now. Looks like
the exit code should be 1.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References