Search in sources :

Example 1 with Help

use of com.github.rvesse.airline.help.Help in project druid by druid-io.

the class Main method main.

@SuppressWarnings("unchecked")
@SuppressForbidden(reason = "System#out")
public static void main(String[] args) {
    final CliBuilder<Runnable> builder = Cli.builder("druid");
    builder.withDescription("Druid command-line runner.").withDefaultCommand(Help.class).withCommands(Help.class, Version.class);
    List<Class<? extends Runnable>> serverCommands = Arrays.asList(CliCoordinator.class, CliHistorical.class, CliBroker.class, CliOverlord.class, CliIndexer.class, CliMiddleManager.class, CliRouter.class);
    builder.withGroup("server").withDescription("Run one of the Druid server types.").withDefaultCommand(Help.class).withCommands(serverCommands);
    List<Class<? extends Runnable>> toolCommands = Arrays.asList(DruidJsonValidator.class, PullDependencies.class, CreateTables.class, DumpSegment.class, ResetCluster.class, ValidateSegments.class, ExportMetadata.class);
    builder.withGroup("tools").withDescription("Various tools for working with Druid").withDefaultCommand(Help.class).withCommands(toolCommands);
    builder.withGroup("index").withDescription("Run indexing for druid").withDefaultCommand(Help.class).withCommands(CliHadoopIndexer.class);
    builder.withGroup("internal").withDescription("Processes that Druid runs \"internally\", you should rarely use these directly").withDefaultCommand(Help.class).withCommands(CliPeon.class, CliInternalHadoopIndexer.class);
    final Injector injector = GuiceInjectors.makeStartupInjector();
    final ExtensionsConfig config = injector.getInstance(ExtensionsConfig.class);
    final Collection<CliCommandCreator> extensionCommands = Initialization.getFromExtensions(config, CliCommandCreator.class);
    for (CliCommandCreator creator : extensionCommands) {
        creator.addCommands(builder);
    }
    final Cli<Runnable> cli = builder.build();
    try {
        final Runnable command = cli.parse(args);
        if (!(command instanceof Help)) {
            // Hack to work around Help not liking being injected
            injector.injectMembers(command);
        }
        command.run();
    } catch (ParseException e) {
        System.out.println("ERROR!!!!");
        System.out.println(e.getMessage());
        System.out.println("===");
        cli.parse(new String[] { "help" }).run();
        System.exit(1);
    }
}
Also used : Help(com.github.rvesse.airline.help.Help) Injector(com.google.inject.Injector) ParseException(com.github.rvesse.airline.parser.errors.ParseException) ExtensionsConfig(org.apache.druid.guice.ExtensionsConfig) SuppressForbidden(io.netty.util.SuppressForbidden)

Aggregations

Help (com.github.rvesse.airline.help.Help)1 ParseException (com.github.rvesse.airline.parser.errors.ParseException)1 Injector (com.google.inject.Injector)1 SuppressForbidden (io.netty.util.SuppressForbidden)1 ExtensionsConfig (org.apache.druid.guice.ExtensionsConfig)1