commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Oxspring <>
Subject [CLI] Application utility class (was Re: [CLI] PatternOptionBuilder)
Date Sat, 27 Mar 2004 11:10:36 GMT
Moving to the list for wider comment. (will reply separately)

-------- Original Message --------
Subject: Re: [CLI] PatternOptionBuilder
Date: Fri, 26 Mar 2004 17:39:21 -0500 (EST)
From: Michael Heuer <>
To: Rob Oxspring <>

On Fri, 26 Mar 2004, Rob Oxspring wrote:

> I'm pretty sure this is doable in cli2, is there any particular part of
> it that's causing you problems?

I guess I'm looking for something like the attached file

(although to be honest I don't really like the class name)

I'm a bit confused on the createOptions() method -- do I have this right
by returning a Group containing all the Options?  Perhaps you could show
me or point me to an example of what this method's implementation might
look like.

If I wanted the Application class to add "standard" options like --help
and --verbose should I just add those to the Group that is returned?

In my 1.0 version the abstract class held an instance of Options and the
abstract method was

   protected abstract addOption(Option);

Thank you for your help.


-------- Original Message --------
Subject: Re: [CLI] PatternOptionBuilder
Date: Fri, 26 Mar 2004 17:53:11 -0500 (EST)
From: Michael Heuer <>
To: Rob Oxspring <>

I guess I'd also like it if


did something better than return null if an OptionException is thrown.  Or
maybe I should call parser.parse(String[]) and deal with the exceptions

This illustrates the problem:

$ java -classpath "commons-cli-2.0.jar;." MyTask --not-a-valid-option
Unexpected --not-a-valid-option while processing

hello world.


import org.apache.commons.cli2.Group;
import org.apache.commons.cli2.Application;

public class MyTask
     extends Application
     public MyTask(final String[] args)

     protected Group createOptions()
         return new GroupBuilder().create();
     public void run()
         System.out.println("hello world.");

     public static void main(final String args[])
         MyTask mt = new MyTask(args);;

View raw message