airlift / airline

Java annotation-based framework for parsing Git like command line structures
Apache License 2.0
846 stars 141 forks source link

Add optionEndsValues bool to the @Option annotation #37

Closed Randgalt closed 9 years ago

Randgalt commented 9 years ago

Add optionEndsValues bool to the @Option annotation to allow for variable length parameter lists. When true, this allows options with arity > 1 to end when a new option is encountered, even if the set arity hasn't been reached.

electrum commented 9 years ago

What if the option is the last one? How do you separate the extra args from positional arguments?

Randgalt commented 9 years ago

It should be the same. If it's the last option it will just collate any remaining values. I'll add a test for that.

Randgalt commented 9 years ago

Can you let me know if you'll merge this (or something like it)? I'm counting on this behavior and will need to find an alternative otherwise.

electrum commented 9 years ago

Sorry, I'll expand on my question. Suppose you have a command like "git add" that takes positional arguments:

git add foo bar

How would this new feature interact with that? Suppose you make --junk a vararg option:

git add --junk abc xzy foo bar

Is this treated as not having an positional arguments? I think this would need to support -- to allow positional arguments:

git add --junk abc xyz -- foo bar
electrum commented 9 years ago

Can you point to any existing UNIX tools that work this way? This seems very non-standard. A more common way of doing it is either specifying the option multiple times, or having a delimiter:

command --junk abc --junk xyz
command --junk abc,xyz
Randgalt commented 9 years ago

I didn't think of the multiple options. I'll check if that works currently and, if so, close this.

dain commented 9 years ago

We use the multiple repeated options in Presto for session properties.

Randgalt commented 9 years ago

OK - that multiple option technique works. Thanks.