You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bob mcwhirter <bo...@werken.com> on 2002/06/14 06:08:52 UTC

[CLI] multiple args

Howdy folks--

We allow multiple values for an argument now, so that

	-D foo bar baz

results in 'D' having 3 args.

Now, I'd like to have multiple instances of single-arg options.

To get the above, you'd have to do

	-D foo -D bar -D baz

Why?

	maven -D maven.username=werken maven:deploy-site

I want to allow multiple -D options, and have them anywhere
in the command-line.

Right now, that's interp'd as

	maven -D maven.username=werken -D maven:deploy-site

Which is wrong.

Workaround is reordering the command-line:

	maven maven:deploy-site -D maven.username=werken

Seems like an arbitrary restriction.

Any thoughts on how to hack in multiple-instances-single-arg options
without adding yet-another-boolean-parameter to all of the signatures?

Maybe time to re-arch, and have folks instantiate NoArgOption,
SingleArgOption and MultiArgOption subclasses, and add them
directly to Options?

	-bob


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


Re: [CLI] multiple args

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "John Keyes" <jb...@mac.com>
> This is one of the reasons why I will be trying to
> get as much documentation as possible together.  The
> idea I have is to create a number of examples that
> mimic the command line of popular command line tools,
> e.g. tar, java, ant(when I get my multiple parsers
> in there :), and any others that people would like
> to recommend.  Then have a piece of documentation to
> describe each example.  It would effectively be a FAQ
> by example.

Sounds *great*.

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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


Re: [CLI] multiple args

Posted by bob mcwhirter <bo...@werken.com>.
On Fri, 14 Jun 2002, John Keyes wrote:

> This is one of the reasons why I will be trying to
> get as much documentation as possible together.  The
> idea I have is to create a number of examples that
> mimic the command line of popular command line tools,
> e.g. tar, java, ant(when I get my multiple parsers
> in there :), and any others that people would like
> to recommend.  Then have a piece of documentation to
> describe each example.  It would effectively be a FAQ
> by example.

fwiw, the stopAtFirstNonDashArg parameter (or whatever
I called) was specifically for cvs and javac functionality.

	cvs -d <arg> <argList>

Where you can then subsequently parse <argList> yet again, to get out
a <cmd> and its own flags.

	-bob


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


Re: [CLI] multiple args

Posted by John Keyes <jb...@mac.com>.
This is one of the reasons why I will be trying to
get as much documentation as possible together.  The
idea I have is to create a number of examples that
mimic the command line of popular command line tools,
e.g. tar, java, ant(when I get my multiple parsers
in there :), and any others that people would like
to recommend.  Then have a piece of documentation to
describe each example.  It would effectively be a FAQ
by example.

-John K

On Friday, June 14, 2002, at 04:36 , bob mcwhirter wrote:

>>> Maybe I need to look more into CLI -- I might be missing something...
>>> it's been on my todo list for way too long now.  :)
>>
>> Yah know, maybe I do too.  I was thinking that if I said 'false' to
>> allowMultipleArgs parameter that I could only use -D once on the
>> command-line.  Maybe not.  I'll go experiment.
>
> Okay, my error...
>
> Setting the multipleArgs parameter to false doesn't mean you can't
> have the option on the command-line multiple times...
>
> Never mind, [cli] is perfect.
>
> 	-bob
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-
> help@jakarta.apache.org>
>


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


Re: [CLI] multiple args

Posted by "Michael A. Smith" <ma...@apache.org>.
On Fri, 14 Jun 2002, bob mcwhirter wrote:
> > > Maybe I need to look more into CLI -- I might be missing something...  
> > > it's been on my todo list for way too long now.  :)
> > 
> > Yah know, maybe I do too.  I was thinking that if I said 'false' to 
> > allowMultipleArgs parameter that I could only use -D once on the
> > command-line.  Maybe not.  I'll go experiment.
> 
> Okay, my error...
> 
> Setting the multipleArgs parameter to false doesn't mean you can't
> have the option on the command-line multiple times...
> 
> Never mind, [cli] is perfect.

:)

michael


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


Re: [CLI] multiple args

Posted by bob mcwhirter <bo...@werken.com>.
> > Maybe I need to look more into CLI -- I might be missing something...  
> > it's been on my todo list for way too long now.  :)
> 
> Yah know, maybe I do too.  I was thinking that if I said 'false' to 
> allowMultipleArgs parameter that I could only use -D once on the
> command-line.  Maybe not.  I'll go experiment.

Okay, my error...

Setting the multipleArgs parameter to false doesn't mean you can't
have the option on the command-line multiple times...

Never mind, [cli] is perfect.

	-bob


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


Re: [CLI] multiple args

Posted by bob mcwhirter <bo...@werken.com>.
On Thu, 13 Jun 2002, Michael A. Smith wrote:

> On Fri, 14 Jun 2002, bob mcwhirter wrote:
> > > > Any thoughts on how to hack in multiple-instances-single-arg options
> > > > without adding yet-another-boolean-parameter to all of the signatures?
> > > 
> > > How about an "end-of-list" marker:
> > > 
> > > maven -D macen.username=werken -- maven:deploy-site
> > 
> > While technically a good solution, it breaks compatibility with other
> > tools such as javac, ant, make, and most any other compiler out there.
> 
> except that I don't think any of those allow arbitrary number of 
> options unless they are last on the command line.  Most options take 
> only a single argument and when they take multiple you're usually stuck 
> with specifying the option multiple times, once per argument.  So, I'm 
> not exactly sure how its not compatible.

No, that's exactly what I want.

I'd be happy if I had to do this:

	maven -Done -Dtwo -Dthree=value myTarget

That'd be just dandy by me.

Basically, just trying to reproduce javac's -D flag.

javac doesn't allow

	javac -D one two three=value MyClass

and it doesn't require

	javac MyClass -D one two three=value 

		or

	javac -D one two three=value -- MyClass

but, it does allow/require

	javac -Done -Dtwo -Dthree=value MyClass


And that's what I want.

> I'm not sure how much Ant's command-line interface has changed since I
> last did much in-depth playing with Ant, but from what I remember their
> command syntax was similar to this:
> 
>   ant [options] target [target ...]
> 
> None of the options allowed more than one argument, 

You're right.  But, you can specify the -D multiple times on the command-line.

> Maybe I need to look more into CLI -- I might be missing something...  
> it's been on my todo list for way too long now.  :)

Yah know, maybe I do too.  I was thinking that if I said 'false' to 
allowMultipleArgs parameter that I could only use -D once on the
command-line.  Maybe not.  I'll go experiment.

	-bob


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


Re: [CLI] multiple args

Posted by "Michael A. Smith" <ma...@apache.org>.
On Fri, 14 Jun 2002, bob mcwhirter wrote:
> > > Any thoughts on how to hack in multiple-instances-single-arg options
> > > without adding yet-another-boolean-parameter to all of the signatures?
> > 
> > How about an "end-of-list" marker:
> > 
> > maven -D macen.username=werken -- maven:deploy-site
> 
> While technically a good solution, it breaks compatibility with other
> tools such as javac, ant, make, and most any other compiler out there.

except that I don't think any of those allow arbitrary number of 
options unless they are last on the command line.  Most options take 
only a single argument and when they take multiple you're usually stuck 
with specifying the option multiple times, once per argument.  So, I'm 
not exactly sure how its not compatible.

> I want to be able to reproduce ant's command-line interface, which
> doesn't require the --.

I'm not sure how much Ant's command-line interface has changed since I
last did much in-depth playing with Ant, but from what I remember their
command syntax was similar to this:

  ant [options] target [target ...]

None of the options allowed more than one argument, so I'm not sure how 
an argument type that has multiple arguments would make it not 
compatible (the Ant command line tool wouldn't use the multiple argument 
option thingy).  If you want multiple -D properties, you're required to 
specify -D multiple times.  

Maybe I need to look more into CLI -- I might be missing something...  
it's been on my todo list for way too long now.  :)

regards,
michael


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


Re: [CLI] multiple args

Posted by bob mcwhirter <bo...@werken.com>.
> > Any thoughts on how to hack in multiple-instances-single-arg options
> > without adding yet-another-boolean-parameter to all of the signatures?
> 
> How about an "end-of-list" marker:
> 
> maven -D macen.username=werken -- maven:deploy-site

While technically a good solution, it breaks compatibility with other
tools such as javac, ant, make, and most any other compiler out there.

I want to be able to reproduce ant's command-line interface, which
doesn't require the --.

	-bob


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


Re: [CLI] multiple args

Posted by "Michael A. Smith" <ma...@apache.org>.
On Fri, 14 Jun 2002, bob mcwhirter wrote:
> I want to allow multiple -D options, and have them anywhere
> in the command-line.
> 
> Right now, that's interp'd as
> 
> 	maven -D maven.username=werken -D maven:deploy-site
> 
> Which is wrong.
> 
> Workaround is reordering the command-line:
> 
> 	maven maven:deploy-site -D maven.username=werken
> 
> Seems like an arbitrary restriction.
> 
> Any thoughts on how to hack in multiple-instances-single-arg options
> without adding yet-another-boolean-parameter to all of the signatures?

How about an "end-of-list" marker:

maven -D macen.username=werken -- maven:deploy-site

regards,
michael


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


Re: [CLI] multiple args

Posted by Henri Yandell <ba...@generationjava.com>.
This probably isn't a general solution, but how about rules for the
leftover array?

So for a command that runs Maven, it would try harder to fill the leftover
array with one value than the -D flag?

Another idea would be legal patterns for argument values? So below you
could specify that the -D argument must contain an '=' sign or some such?

Just ideas. Definite flaws to them.

Hen

On Fri, 14 Jun 2002, bob mcwhirter wrote:

>
> Howdy folks--
>
> We allow multiple values for an argument now, so that
>
> 	-D foo bar baz
>
> results in 'D' having 3 args.
>
> Now, I'd like to have multiple instances of single-arg options.
>
> To get the above, you'd have to do
>
> 	-D foo -D bar -D baz
>
> Why?
>
> 	maven -D maven.username=werken maven:deploy-site
>
> I want to allow multiple -D options, and have them anywhere
> in the command-line.
>
> Right now, that's interp'd as
>
> 	maven -D maven.username=werken -D maven:deploy-site
>
> Which is wrong.
>
> Workaround is reordering the command-line:
>
> 	maven maven:deploy-site -D maven.username=werken
>
> Seems like an arbitrary restriction.
>
> Any thoughts on how to hack in multiple-instances-single-arg options
> without adding yet-another-boolean-parameter to all of the signatures?
>
> Maybe time to re-arch, and have folks instantiate NoArgOption,
> SingleArgOption and MultiArgOption subclasses, and add them
> directly to Options?
>
> 	-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>