All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.governator.commons_cli.Cli Maven / Gradle / Ivy

There is a newer version: 1.17.13
Show newest version
package com.netflix.governator.commons_cli;

import com.google.inject.AbstractModule;
import com.google.inject.ProvisionException;
import com.netflix.governator.annotations.binding.Main;
import com.netflix.governator.guice.LifecycleInjector;

public class Cli {
    /**
     * Utility method to start the CommonsCli using a main class and command line arguments
     * 
     * @param mainClass
     * @param args
     */
    public static void start(Class mainClass, final String[] args) {
        try {
            LifecycleInjector.bootstrap(mainClass, new AbstractModule() {
                @Override
                protected void configure() {
                    bind(String[].class).annotatedWith(Main.class).toInstance(args);
                }
            });
        } catch (Exception e) {
            throw new ProvisionException("Error instantiating main class", e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy