You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by John Keyes <jb...@mac.com> on 2002/04/29 11:46:21 UTC

[SANDBOX-CLI] Multiple value support added

All,

I have added support for multiple values to CLI.  This
is useful for specifying lists of values e.g.

myUtil --include one two three -list *.java

So the values for the include option are [one, two, three].

I will put this together into a patch later today and
post the URL.

CLI uses char as the id of an option.  I think this limits
developers too much.  Lets use ant as an example.  To specify
a build file in ant the -buildfile option is required.  This
type of flag cannot be used in CLI.  It can be either -b or
--buildfile but not -buildfile.  I would like to change the key
from char to String.  This could be made API compatible by 
delegating the current methods that use char to the new methods
that will use String.

Comments please,
-John K


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by John Keyes <jb...@mac.com>.
> I think POSIX would argue that -buildfile is the '-b' option
> with an argument of 'uildfile'.  Or possibly equiv to 
> -b -u -i -l -d -f -i -l -e.
> 
> A dash preceeds a single-character switches (or a sequence of single
> character switches), while 2 dashes preceed a 'word'-based switch.
> 
> I was intentionally staying POSIXy with CLI.
> 
> So, right now, -1 on the '-buildfile' type of option, unless
> convinced otherwise.
Fair point.  I forgot about that.  Could we extend cli to 
support functionality like this?  We could have specific Options
implementations e.g. PosixOptions.

e.g. 
interface PosixOptions
{
  // required methods
}

class PosixOptionsImpl implements PosixOptions
{
  // implement all of the methods on PosixOptions
  // and have them delegate appropriately to 
  // Options or other classes were appropriate
  // e.g. PosixParser, SimpleParser
}

interface CommandLineParser
{
  public List parse( String[] args ); 
}

class PosixParser implements CommandLineParser
{
  ..
}

class SimpleParser implements CommandLineParser
{
  ..
}

I haven't gone through the whole scenario but they
are my initial thoughts on it.

-John K

> 
> 	-bob
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by John Keyes <jb...@mac.com>.
> > > I think POSIX would argue that -buildfile is the '-b' option
> > > with an argument of 'uildfile'.  Or possibly equiv to
> > > -b -u -i -l -d -f -i -l -e.
> > 
> > I would agree, except that Sun seem happy to use the -buildfile style.
> > Supporting both seems important to me.
> 
> That's a slipperly slope though.  We're all angered when Microsoft
> embraces and extends a technology or standard.  I think we should have
> a similar reaction when Sun, IBM or anyone else does it too.
Agreed.  

> It'd be fine, if we follow John's suggestion of having different
> styles of parser, possibly even with the POSIX one as the default.
> You should have to go out of your way to do something non-standard
> (non-POSIX, in this case).
Cool.  When I have the multiple value patch together I was thinking of
having a bash at refactoring some of the parsing code anyway (its just
a bit hard to follow at the moment, and even more so with the multiple
value stuff going in).  So I will have a go at drafting a design for
this.  I think the main thing here is to have it as simple as possible.
The last thing we want is for users to wonder "what the hell is going 
on, all I want to do is parse a command line?".

An idea I have for testing is to add an ApplicationTest unit test that
has testXXX methods, where XXX is an real world command line utility
e.g. testJava, testJavac, testTar, testChmod, testUname, testCd, etc.
Not only will we have some good test coverage we'll also have ready
to wear demos :-)

-John K


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by John Keyes <jb...@mac.com>.
> If I can find some time I keep meaning to pour through CLI and push as
> much as I can from the one I use into it. In my continuing quest to dump
> my own code and replace it with Apache code.
Exact same reason why I started doing this :-)

-John K


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by Henri Yandell <ba...@generationjava.com>.

On Mon, 29 Apr 2002, bob mcwhirter wrote:

> > I would agree, except that Sun seem happy to use the -buildfile style.
> > Supporting both seems important to me.
>
> That's a slipperly slope though.  We're all angered when Microsoft
> embraces and extends a technology or standard.  I think we should have
> a similar reaction when Sun, IBM or anyone else does it too.

Not so sure. I'd expect VB developers to follow the MS embrace and extend,
so why should we Java plebs not follow Sun? :) It is irritating though
yeah.

> It'd be fine, if we follow John's suggestion of having different
> styles of parser, possibly even with the POSIX one as the default.
> You should have to go out of your way to do something non-standard
> (non-POSIX, in this case).

+1

If I can find some time I keep meaning to pour through CLI and push as
much as I can from the one I use into it. In my continuing quest to dump
my own code and replace it with Apache code.

Hen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by bob mcwhirter <bo...@werken.com>.
> > I think POSIX would argue that -buildfile is the '-b' option
> > with an argument of 'uildfile'.  Or possibly equiv to
> > -b -u -i -l -d -f -i -l -e.
> 
> I would agree, except that Sun seem happy to use the -buildfile style.
> Supporting both seems important to me.

That's a slipperly slope though.  We're all angered when Microsoft
embraces and extends a technology or standard.  I think we should have
a similar reaction when Sun, IBM or anyone else does it too.

It'd be fine, if we follow John's suggestion of having different
styles of parser, possibly even with the POSIX one as the default.
You should have to go out of your way to do something non-standard
(non-POSIX, in this case).

	-bob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by Henri Yandell <ba...@generationjava.com>.

On Mon, 29 Apr 2002, bob mcwhirter wrote:

> I think POSIX would argue that -buildfile is the '-b' option
> with an argument of 'uildfile'.  Or possibly equiv to
> -b -u -i -l -d -f -i -l -e.

I would agree, except that Sun seem happy to use the -buildfile style.
Supporting both seems important to me.

Hen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by bob mcwhirter <bo...@werken.com>.
On 29 Apr 2002, John Keyes wrote:

> All,
> 
> I have added support for multiple values to CLI.  This
> is useful for specifying lists of values e.g.
> 
> myUtil --include one two three -list *.java
> 
> So the values for the include option are [one, two, three].
> 
> I will put this together into a patch later today and
> post the URL.
> 
> CLI uses char as the id of an option.  I think this limits
> developers too much.  Lets use ant as an example.  To specify
> a build file in ant the -buildfile option is required.  This
> type of flag cannot be used in CLI.  It can be either -b or
> --buildfile but not -buildfile.  I would like to change the key
> from char to String.  This could be made API compatible by 
> delegating the current methods that use char to the new methods
> that will use String.

I think POSIX would argue that -buildfile is the '-b' option
with an argument of 'uildfile'.  Or possibly equiv to 
-b -u -i -l -d -f -i -l -e.

A dash preceeds a single-character switches (or a sequence of single
character switches), while 2 dashes preceed a 'word'-based switch.

I was intentionally staying POSIXy with CLI.

So, right now, -1 on the '-buildfile' type of option, unless
convinced otherwise.

	-bob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SANDBOX-CLI] Multiple value support added

Posted by bob mcwhirter <bo...@werken.com>.
> I have added support for multiple values to CLI.  This
> is useful for specifying lists of values e.g.
> 
> myUtil --include one two three -list *.java
> 
> So the values for the include option are [one, two, three].

+1, great idea.  

	-bob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>