https://github.com/israfil/jcommander-inject also does some module/binding work for you (and a dagger version is also planned, but the guice version works today, or did last I used it). Point is - you can use JCommander and guice with little boilerplate.
On Sat Oct 11 2014 at 5:28:55 PM Kevin Burton <burtona...@gmail.com> wrote: > Cool.. jcommander doesn't look that bad. Similar to airline... wonder > which one is best.. :-P > > > On Thursday, October 9, 2014 7:05:46 PM UTC-7, Cédric Beust ♔ wrote: > >> I'm not sure dependency injection is a good match for command line >> parsing: because such parsing is dynamic, you'd basically have providers >> for everything, while DI is usually better suited for configuration with >> values that are known at build time, or at least, very early in the life >> cycle of the app. >> >> Other than that, obviously, for command line parsing, I use >> http://jcommander.org ;) >> >> >> -- >> Cédric >> >> >> On Thu, Oct 9, 2014 at 6:17 PM, Kevin Burton <burto...@gmail.com> wrote: >> > It seems like one way to handle command line parameters could be to do >>> named injection. >>> >>> So you would annotate with a name something like --foo >>> >>> And then you would just modify your bindings to inject that parameter >>> but get the value from the command line arguments. >>> >>> But that would be very simple command line handling. It wouldn't >>> support complex command line apps. >>> >>> Then there are systems like Airline: >>> >>> https://github.com/airlift/airline >>> >>> ... so it seems maybe a combination of the two would make a great way to >>> build command line applications. >>> >>> You would get dependency injection, and get command line argument >>> handling. >>> >>> How have other people handled this? I'd rather not re-invent the wheel >>> here if there's a "best practice" way of doing this. >>> >> -- >>> You received this message because you are subscribed to the Google >>> Groups "google-guice" group. >>> >> To unsubscribe from this group and stop receiving emails from it, send an >>> email to google-guice...@googlegroups.com. >>> To post to this group, send email to google...@googlegroups.com. >> >> >>> Visit this group at http://groups.google.com/group/google-guice. >>> To view this discussion on the web visit https://groups.google.com/d/ >>> msgid/google-guice/4c2fbd69-46d9-4c5b-b253-b19bef882214% >>> 40googlegroups.com >>> <https://groups.google.com/d/msgid/google-guice/4c2fbd69-46d9-4c5b-b253-b19bef882214%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to google-guice+unsubscr...@googlegroups.com. > To post to this group, send email to google-guice@googlegroups.com. > Visit this group at http://groups.google.com/group/google-guice. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-guice/0cf0ce89-bbf0-42ee-a230-c9c981e21145%40googlegroups.com > <https://groups.google.com/d/msgid/google-guice/0cf0ce89-bbf0-42ee-a230-c9c981e21145%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscr...@googlegroups.com. To post to this group, send email to google-guice@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/CAHsNDCSDRXYGvp5a6e85hQxB7tYSzsn%3DehX3k5o9jU%2Bzkqcg0g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.