airlift / airline

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

Allow default commands to take options and/or arguments. #19

Closed cheddar closed 10 years ago

cheddar commented 10 years ago

1) Adjust Parser to determine default commands as part of the parsing so that they can get options and arguments injected as well

electrum commented 10 years ago

Can you remove the "1)" from your commit message and follow the standard commit message format? http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

electrum commented 10 years ago

How does this handle differentiating arguments and command names? If you allow the default command to take arbitrary arguments, then you can't add commands later without breaking compatibility.

cheddar commented 10 years ago

I'll adjust the commit message... Once I figure out how to edit a commit message ;).

The question of compatibility seems like something for the user to decide. Fwiw, my use case is that I just want to package something up with a single command and use airline's parsing stuff to figure options out for me. This is a convenience change that allows for my use case without actually eliminating any functionality (assuming that unit tests passing equals functional maintenance).

At the end of the day, if you do add a verb that generates ambiguous command lines to your application, then you have the option of removing the default command. It's always possible to specify exactly what you are calling by specifying the group/verb.

I'd actually argue that if you don't want to allow for arguments/options on the default command, then I don't really understand why the default command is something the user can provide. It seems like it should just always default to Help and not even make you believe you have a choice in the matter, or is there some other thing that you might want to do from the command-line as a default without the ability to pass in arguments?

dain commented 10 years ago

I have a branch that I never pushed that adds a new build for single commands. Would that work for you?

cheddar commented 10 years ago

Yes, if it allows me to just have a single command and use the parsing stuff, that's exactly what I want. From what I saw, the way I thought I was supposed to achieve that was with a default command. If there's another way to achieve it, I'll give this up and use that.

cheddar commented 10 years ago

https://github.com/airlift/airline/pull/20 fixes this, so closing.