Torsten Curdt wrote:
The proposed release is available at:
http://people.apache.org/~roxspring/cli/


Rob,

I've been playing with the CLI2 stuff now.
Great stuff! ...but something I found confusing

Let's say I create my option like this:

      final Set set = new HashSet();
      set.add("a1");
      set.add("a2");
      set.add("a3");

      final Option oOption1 =
            oBuilder
            .withDescription(Messages.getString("Main.cli.option." +
CommandlineOption.ALGORITHM))
            .withRequired(true)
            .withArgument(
                 aBuilder
                 .withMinimum(1)
                 .withMaximum(1)
                 .withValidator(new EnumValidator(set))
                 .create())
             .withLongName(CommandlineOption.ALGORITHM)
             .create();

And then later want to get the value from it:

  final String v =
    (String) cmd.getValue("--" + CommandlineOption.ALGORITHM);


I find adding "--" quite inconvenient. Why here this prefix?

The prefix is needed here because the getValue() method takes any string as might be entered by the user. I understand that it can be a bit confusing but I tend to see people using hard coded strings in their application where asking for the values of "--algorithm" is quite intuitive. Alternatively I tend to set up an Option instance as a constant:


  Option ALGORITHM = ...

and later:

  final String v = (String) cmd.getValue(ALGORITHM)



Also I am wondering what you think about adding some getValuesAsXXX functions. Alway having an explicit cast is kind of annoying.

Or am I missing something?

There was a plan a while back of adding a TypedCommandLine that would wrap a CommandLine instance and provide such methods. I didn't get around to it since there wasn't much demand.


Could be added pretty easily but I think we should push for a 2.0 now and make the new methods available in a 2.1 so that the api can settle.

THoughts?

Rob


cheers -- Torsten

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



Reply via email to