commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject RE: [CLI] new design possibly?
Date Thu, 06 Feb 2003 12:29:43 GMT
On Thu, 2003-02-06 at 10:55, Tim Anderson wrote:
> Not a critique on your design, but an RFE ;)
> 
> One useful addition to CLI would be to be able to specify
> mutually exclusive sets of arguments, which contain common
> options. Eg:
> 
> usage: org.apache.commons.sql.util.DDL <commands>
> commands:
>   -execute -db <db> [-version <version>] <db-props> -schema <path>
[-drop]
>   -print -db <provider> [-version <version>] [-drop]
>   -list
>   -types <db-props>
> 
> db-props:
>   -driver <driver> -url <url> [-user <user>] [-password <password>]
> 
> In the above, -execute, -print, -list and -types are mutually exclusive,
> and <db-props> represents a set of arguments which are applicable to both
> -execute and -types.
> 
I have almost finished work on child options (needs more testing)
but this will support the behaviour you describe here (I think).

So it would be something like:
Option driver = new Option();
Option url = new Option();
Set opts = new HashSet();
opts.add(driver);
opts.add(url);

Option types = new Option();
types.addChildOptions(opts);

Option execute = new Option();
execute.addChildOptions(opts);

.....

> It would be nice to be able to do something like:
> 
> OptionSet dbprops = new OptionSet("db-props");
> dbprops.addOption("driver", true, ....);
> dbprops.addOption("url", true, ....);
> ...
> 
> OptionSet execute = new OptionSet("execute", "executes DDL for a schema");
> execute.addOption("db", true, ....);
> execute.addOptionSet(dbprops);
> ...
> 
> OptionSet types = new OptionSet("types", "generate type info");
> types.addOptionSet(dbprops);
> 
> OptionGroup group = new OptionGroup();
> group.addOptionSet(execute);
> ...
> group.addOptionSet(types);
> 
> 
> The advantages of this are that:
> . CLI can do more of the validation
> . HelpFormatter can be enhanced to format wierder command line 
>   syntaxes (such as the above), rather than doing it manually in code.
> 
> Thoughts?
I think the framework is all there for it at the moment, just some
small tweaks are needed.

Cheers,
-John K

> 
> Thanks,
> 
> Tim
> 
> 
> > -----Original Message-----
> > From: John Keyes [mailto:jbjk@mac.com]
> > Sent: Thursday, February 06, 2003 10:59 AM
> > To: commons-dev
> > Subject: [CLI] new design possibly?
> > 
> > 
> > I have grown disgruntled with CLIs current design so I have done
> > some thinking on the matter (BTW, I know I should have done
> > this before a 1.0 release).  Before I finish working on it
> > I thought I'd seek comments from you guys.  Check out the
> > class diagram at http://www.integralsource.com/cli/datatype.gif
> > and let me hear your comments.
> > 
> > Thanks,
> > -John K
> > - - - - - - - - - - - - - - - - - - - - - - -
> > Jakarta Commons CLI
> > http://jakarta.apache.org/commons/cli
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
-- 
John Keyes <jbjk@mac.com>


---------------------------------------------------------------------
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