public static Object execute(File artemisHome, File artemisInstance, String... args)
      throws Exception {
    try {
      return internalExecute(artemisHome, artemisInstance, args);
    } catch (ConfigurationException configException) {
      System.err.println(configException.getMessage());
      System.out.println();
      System.out.println(
          "Configuration should be specified as 'scheme:location'. Default configuration is 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'");
      return configException;
    } catch (CLIException cliException) {
      System.err.println(cliException.getMessage());
      return cliException;
    } catch (RuntimeException re) {
      System.err.println(re.getMessage());
      System.out.println();

      Cli<Action> parser = builder(null).build();

      parser.parse("help").execute(ActionContext.system());
      return re;
    }
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  public static void main(String[] args) {
    CliBuilder<Runnable> builder =
        Cli.<Runnable>builder("juseppe")
            .withDescription("Jenkins Update Site Embedded for Plugin Publishing Easily")
            .withDefaultCommand(Help.class)
            .withCommands(
                Help.class,
                ServeCommand.class,
                GenerateCommand.class,
                EnvCommand.class,
                PrintCertCommand.class);

    Runnable parse = builder.build().parse(args);
    parse.run();

    if (parse instanceof JuseppeCommand) {
      System.exit(((JuseppeCommand) parse).getExitCode());
    }
  }
  private static Cli.CliBuilder<Action> builder(File artemisInstance) {
    String instance =
        artemisInstance != null
            ? artemisInstance.getAbsolutePath()
            : System.getProperty("artemis.instance");
    Cli.CliBuilder<Action> builder =
        Cli.<Action>builder("artemis")
            .withDescription("ActiveMQ Artemis Command Line")
            .withCommand(HelpAction.class)
            .withCommand(Producer.class)
            .withCommand(Consumer.class)
            .withCommand(Browse.class)
            .withDefaultCommand(HelpAction.class);

    if (instance != null) {
      builder
          .withGroup("data")
          .withDescription(
              "data tools group (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print)")
          .withDefaultCommand(HelpData.class)
          .withCommands(
              PrintData.class,
              XmlDataExporter.class,
              XmlDataImporter.class,
              DecodeJournal.class,
              EncodeJournal.class,
              CompactJournal.class);
      builder = builder.withCommands(Run.class, Stop.class, Kill.class);
    } else {
      builder
          .withGroup("data")
          .withDescription("data tools group (print) (example ./artemis data print)")
          .withDefaultCommand(HelpData.class)
          .withCommands(PrintData.class);
      builder = builder.withCommand(Create.class);
    }

    return builder;
  }
Exemplo n.º 4
0
  @SuppressWarnings("unchecked")
  public static void main(String[] args) {
    final Cli.CliBuilder<Runnable> builder = Cli.builder("druid");

    builder
        .withDescription("Druid command-line runner.")
        .withDefaultCommand(Help.class)
        .withCommands(Help.class, Version.class);

    builder
        .withGroup("server")
        .withDescription("Run one of the Druid server types.")
        .withDefaultCommand(Help.class)
        .withCommands(
            CliCoordinator.class,
            CliHistorical.class,
            CliBroker.class,
            CliRealtime.class,
            CliOverlord.class,
            CliMiddleManager.class,
            CliRouter.class);

    builder
        .withGroup("example")
        .withDescription("Run an example")
        .withDefaultCommand(Help.class)
        .withCommands(CliRealtimeExample.class);

    builder
        .withGroup("tools")
        .withDescription("Various tools for working with Druid")
        .withDefaultCommand(Help.class)
        .withCommands(
            DruidJsonValidator.class,
            PullDependencies.class,
            CreateTables.class,
            InsertSegment.class,
            DumpSegment.class,
            ResetCluster.class,
            ValidateSegments.class);

    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);
    }
  }