I support that in Giulius: http://timboudreau.com/builds/job/mastfrog-parent/lastSuccessfulBuild/artifact/giulius-modules/giulius-parent/giulius-settings/target/apidocs/com/mastfrog/settings/SettingsBuilder.html#parseCommandLineArguments(java.lang.String...)
public static void main(String... args) { // read /etc/etcFileName.properties, ~/etcFileName.properties, ./etcFileName.properties and override with // command-line args Settings settings = new SettingsBuilder("etcFileName").addDefaultLocations().parseCommandLineArguments(args); // Build the injector, binding all settings (string key/value pairs) to @Named Dependencies deps = Dependencies.builder().add(new MyModule()).add(settings, Namespace.DEFAULT).build(); deps.getInstance(Whatever.class); } See http://timboudreau.com/builds for how to include it in a Maven project; code here: https://github.com/timboudreau/giulius -Tim On Thursday, October 9, 2014 9:17:28 PM UTC-4, Kevin Burton 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+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/8ecf29d1-89f0-4ca4-accc-c09cbf87e7a7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.