commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Herve Quiroz <herve.qui...@esil.univ-mrs.fr>
Subject Re: [CLI] Version 2.0 - API
Date Thu, 06 Mar 2003 18:15:54 GMT


On Thu, 6 Mar 2003, John Keyes wrote:

> > Now speaking of something not closely related, I remember reading on this
> > list something about OptionGroup that would allow rules like "the
> > --overwrite option is only relevant if an output file is specified with
> > --output". Is this planned (or already done) for CLI-2 ? Because it could
> > possibly get easy with the functor/predicate stuff we discussed.
> This isn't really an OptionGroup issue.  Its more general.  It should
> be possible using child options.  So --output would have child options,
> and when the --output has been handled parse the remaining tokens
> using its child options.  CLI-2 doesn't exist yet and may not depending
> on whether it is voted in.  At the moment its an experiment that aims to
> improve on the work done for 1.0.  So all of this feedback is great as
> it shows that people had problems with 1.0 and would like to see them
> resolved.

Therefore here is another interesting feature:

I used to use a Configuration object (from jakarta-commons-configuration)
to centralize all preferences in my projects. Hence a lot of command line
options need to be propagated to this configuration instance.

// Initialize configuration with some default values...
// Then parse the command line.

if (commnadLine.hasOption("verbose")
  configuration.setProperty("domain.myapp.verbose","true");

if (commandLine.hasOption("port")
  configuration.setProperty("...port",commandLine.optionValue("port"));

It would be nice to specify such a behaviour within the option builder.
And using the functor stuff we discussed, that could stay quite simple.

For example:

OptionBuilder.withPostProcess(new ConfigurationMapperFunctor(config))...
    ...withLongName("argname").create();

I don't know if that makes sense (I am about to leave work...) so I will
re-think of it tonight and tell you tomorrow if I got something
interesting (and clear) enough. ;)

Herve

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message