io.airlift.airline.Cli.CliBuilder Java Examples

The following examples show how to use io.airlift.airline.Cli.CliBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Runner.java    From grpc-proxy with Apache License 2.0 6 votes vote down vote up
private static Cli<Runnable> cli() {
  final CliBuilder<Runnable> builder = Cli.builder("grpc-proxy");

  builder
      .withDescription("A set of example services for testing a gRPC proxy service.")
      .withDefaultCommand(Help.class)
      .withCommand(Help.class)
      .withCommand(HelloWorldClient.Cmd.class);

  builder
      .withGroup("server")
      .withDescription("Run a server")
      .withDefaultCommand(Help.class)
      .withCommand(Help.class)
      .withCommand(ProxyRpcServer.Cmd.class)
      .withCommand(LegacyHttpServer.Cmd.class)
      .withCommand(HelloWorldServer.Cmd.class);

  return builder.build();
}
 
Example #2
Source File: Cli.java    From java-json-benchmark with MIT License 5 votes vote down vote up
public static void main(String[] args) throws RunnerException {
    CliBuilder<Runnable> builder = io.airlift.airline.Cli.<Runnable>builder("bench")
        .withDescription("Benchmark JSON libraries")
        .withDefaultCommand(Help.class)
        .withCommands(Help.class, InfoCommand.class, SerializationCommand.class, DeserializationCommand.class);

    io.airlift.airline.Cli<Runnable> gitParser = builder.build();
    gitParser.parse(args).run();
}
 
Example #3
Source File: CommandLineTool.java    From incubator-taverna-language with Apache License 2.0 5 votes vote down vote up
private static Cli<TvnLangTool> parser() {
	CliBuilder<TvnLangTool> build = Cli.<TvnLangTool> builder("tavlang")
			.withDescription("Convert, manage workflows")
			.withDefaultCommand(HelpCommand.class)
			.withCommand(CommandConvert.class) // Conversion
			.withCommand(HelpCommand.class) // Help
			.withCommand(CommandInspect.class) // Inspect
			.withCommand(CommandValidate.class) // Validate
			.withCommand(CommandVersion.class) // Version
			.withCommand(CommandStat.class); // Statistics

	return build.build();
}
 
Example #4
Source File: Main.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/** method intended for overriding when a different {@link Cli} is desired,
 * or when the subclass wishes to change any of the arguments */
@SuppressWarnings("unchecked")
@Override
protected CliBuilder<BrooklynCommand> cliBuilder() {
    CliBuilder<BrooklynCommand> builder = Cli.<BrooklynCommand>builder(cliScriptName())
            .withDescription("Brooklyn Management Service")
            .withDefaultCommand(cliDefaultInfoCommand())
            .withCommands(
                    HelpCommand.class,
                    cliInfoCommand(),
                    GeneratePasswordCommand.class,
                    CleanOrphanedStateCommand.class,
                    CopyStateCommand.class,
                    ListAllCommand.class,
                    cliLaunchCommand()
            );

    builder.withGroup("cloud-compute")
            .withDescription("Access compute details of a given cloud")
            .withDefaultCommand(HelpCommand.class)
            .withCommands(
                    ComputeListImagesCommand.class,
                    ComputeListHardwareProfilesCommand.class,
                    ComputeListInstancesCommand.class,
                    ComputeGetImageCommand.class,
                    ComputeDefaultTemplateCommand.class,
                    ComputeTerminateInstancesCommand.class);

    builder.withGroup("cloud-blobstore")
            .withDescription("Access blobstore details of a given cloud")
            .withDefaultCommand(HelpCommand.class)
            .withCommands(
                    BlobstoreListContainersCommand.class, 
                    BlobstoreListContainerCommand.class,
                    BlobstoreGetBlobCommand.class);

    return builder;
}
 
Example #5
Source File: StrongboxCLI.java    From strongbox with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    CliBuilder<Runnable> builder = Cli.<Runnable>builder("strongbox")
            .withDescription("Strongbox")
            .withDefaultCommand(Help.class)
            .withCommands(Help.class);

    builder.withCommand(Global.CustomHelp.class);
    builder.withCommand(Global.Version.class);
    builder.withCommand(Global.VersionOption.class);

    builder.withGroup("group")
            .withDescription("Manage Secret Groups")
            .withDefaultCommand(Group.GroupHelp.class)
            .withCommands(Group.Create.class, Group.List.class, Group.Info.class, Group.Delete.class, Group.AttachAdmin.class, Group.DetachAdmin.class, Group.AttachReadOnly.class, Group.DetachReadOnly.class, Group.BackupCommand.class, Group.RestoreCommand.class, Group.MigrateCommand.class);

    builder.withGroup("secret")
            .withDescription("Manage Secrets for a Secret Group")
            .withDefaultCommand(Secret.SecretHelp.class)
            .withCommands(Secret.Create.class, Secret.AddVersion.class, Secret.Get.class, Secret.GetLatest.class, Secret.Delete.class, Secret.ListNames.class, Secret.ListVersions.class, Secret.Update.class);

    builder.withCommand(Gui.OpenGui.class);

    Cli<Runnable> parser = builder.build();
    globalMetadata = parser.getMetadata();

    try {
        parser.parse(args).run();
    } catch (ParseArgumentsUnexpectedException exception) {
        Optional<String> globalOptions = exception.getUnparsedInput().stream()
                .filter(Global.Option::contains)
                .findAny();

        System.err.println(exception.getMessage());
        if (globalOptions.isPresent()) {
            System.err.println(String.format(
                    "Please note: global options like '%s' must be placed before the command,\n" +
                    "  e.g. 'strongbox --global-option [global-option-value] <command> [<args>]'\n" +
                    "  see 'strongbox help <command>' for more information about ordering.",
                    globalOptions.get()));
        } else {
            System.err.println("See 'strongbox help'.");
        }

        System.exit(1);
    } catch (Exception e) {
        boolean stacktrace = stacktraceIsSet(parser.getMetadata(), args);

        if (!stacktrace) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        throw e;
    }
}
 
Example #6
Source File: Denominator.java    From denominator with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  CliBuilder<Runnable> builder = Cli.<Runnable>builder("denominator")
      .withDescription("Denominator: Portable control of DNS clouds")
      .withDefaultCommand(Help.class)
      .withCommand(Help.class)
      .withCommand(PrintVersion.class)
      .withCommand(ListProviders.class);

  builder.withGroup("zone")
      .withDescription("manage zones")
      .withDefaultCommand(ZoneList.class)
      .withCommand(ZoneList.class)
      .withCommand(ZoneAdd.class)
      .withCommand(ZoneUpdate.class)
      .withCommand(ZoneDelete.class);

  builder.withGroup("record")
      .withDescription("manage resource record sets in a zone")
      .withDefaultCommand(ResourceRecordSetList.class)
      .withCommand(ResourceRecordSetList.class)
      .withCommand(ResourceRecordSetGet.class)
      .withCommand(ResourceRecordSetAdd.class)
      .withCommand(ResourceRecordSetApplyTTL.class)
      .withCommand(ResourceRecordSetReplace.class)
      .withCommand(ResourceRecordSetRemove.class)
      .withCommand(ResourceRecordSetDelete.class);

  builder.withGroup("geo")
      .withDescription("manage geo resource record sets in a zone")
      .withDefaultCommand(GeoResourceRecordSetList.class)
      .withCommand(GeoTypeList.class)
      .withCommand(GeoRegionList.class)
      .withCommand(GeoResourceRecordSetList.class)
      .withCommand(GeoResourceRecordSetGet.class)
      .withCommand(GeoResourceRecordSetApplyTTL.class)
      .withCommand(GeoResourceRecordAddRegions.class);

  Cli<Runnable> denominatorParser = builder.build();
  try {
    denominatorParser.parse(args).run();
  } catch (RuntimeException e) {
    if (e instanceof NullPointerException) {
      e.printStackTrace();
    }
    System.err.println(";; error: " + e.getMessage());
    System.exit(1);
  }
  System.exit(0);
}
 
Example #7
Source File: AbstractMain.java    From brooklyn-server with Apache License 2.0 2 votes vote down vote up
/** 
 * Build the commands.
 */
protected abstract CliBuilder<BrooklynCommand> cliBuilder();