Andrew,

Thank you for the suggestion, but it didn't work. Although some of the info in my post was wrong. I claimed I was getting this:

      ShellCommand [-DB|-SCM|-SCW] [-s <source>]

I was actually getting this:

      ShellCommand [-DB|-SCM|-SCW -s <source>]

What I want hasn't changed:

      ShellCommand -DB|-SCM|-SCW [-s <source>]

Adding setMinimum(1) and setMaximum(1) to the initial group didn't change anything.

I have no idea what I'm doing wrong.

If you're interested, here's my code.

        private static void processArgs() {
                DefaultOptionBuilder oBldr = new DefaultOptionBuilder();
                Option dbOption = oBldr
                                                .withShortName("DB")
                                                .withDescription("DB Project")
                                                .create();
                Option scMacOption = oBldr
                                                .withShortName("SCM")
                                                .withDescription("SC for Mac 
Project")
                                                .create();
                Option scWinOption = oBldr
                                                .withShortName("SCW")
                                                .withDescription("SC for Windows 
Project")
                                                .create();
                GroupBuilder gb = new GroupBuilder();
                Group project = gb
                                                .withName("Project")
                                                .withDescription("Specifies the 
Project")
                                                .withOption(dbOption)
                                                .withOption(scMacOption)
                                                .withOption(scWinOption)
                                                .withMinimum(1)
                                                .withMaximum(1)
                                                .create();


                ArgumentBuilder aBldr = new ArgumentBuilder();
                Argument srcArg = aBldr.withName("source")
                                                .withMinimum(1)
                                                .withMaximum(1)
                                                .create();
                Option compatible = oBldr.withShortName("s")
                                                .withShortName("source")
                                                .withDescription("Use Source")
                                                .withRequired(false)
                                                .withArgument(srcArg)
                                                .create();
                Group all = 
gb.withOption(project).withOption(compatible).create();

                HelpFormatter fmt = new HelpFormatter();

                fmt.setGroup(all);
                fmt.setShellCommand("ShellCommand");
                fmt.print();
        }






On Jul 27, 2006, at 4:25 AM, Andrew Shirley wrote:

On Wed, Jul 26, 2006 at 10:06:09PM -0700, Miguel Muñoz wrote:
Comrades,

I want to use CLI 2.0 to create command line options that look like this:

ShellCommand -DB|-SCM|-SCW [-s <source>]

I'm adding three DefaultOptions to a group to get the first set (- DB|-SCM|-SCW), but the trouble is, the user is required to specify one of the three, but I can't figure out a way to make this group required. Consequently, I'm getting this:

ShellCommand [-DB|-SCM|-SCW] [-s <source>]

This is not what I want.

Is there any way to do this?

hi, you should be able to set a minimum number of children needed to
satisfy the group i.e. 1 in this case. This can be done in the
constructor of GroupImpl or if you are using the GroupBuilder
(recommended) then call .withMinimum(1) before .create()

If they have to specify exactly 1, then you will need .withMaximum(1)
as well, otherwise "-DB -SCM -s foo" would be accepted.

hope this helps

Andrew Shirley

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-------------------------------------------

Miguel Muñoz
[EMAIL PROTECTED]
323/225-7285

-------------------------------------------

The Sun, with all those planets revolving around it and dependent on it, can still ripen a vine of grapes like it had nothing else to do in the world.

  -- Galileo

-------------------------------------------

There are seven sins in the world.
    Wealth without work.
    Pleasure without conscience.
    Knowledge without character.
    Commerce without morality.
    Science without humanity.
    Worship without sacrifice.
    Politics without principle.

  -- Mohandas Gandhi

-------------------------------------------

If tyranny and oppression come to this land, it will come in the guise of fighting a foreign enemy.

  -- James Madison



Reply via email to