Java Code Examples for io.airlift.airline.Cli#CliBuilder
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: Launcher.java From presto with Apache License 2.0 | 6 votes |
protected void run(String[] args) { CommandFactory<Runnable> commandFactory = new ExtensionsProvidingCommandFactory<>(getExtensions()); Cli.CliBuilder<Runnable> cli = Cli.<Runnable>builder("launcher") .withCommandFactory(commandFactory) // TODO ignored .withDefaultCommand(Help.class) .withCommand(Help.class); cli .withGroup("env") .withDefaultCommand(Help.class) // TODO should be group aware https://github.com/airlift/airline/issues/72? Otherwise it's required until https://github.com/airlift/airline/pull/71 .withCommand(EnvironmentUp.class) .withCommand(EnvironmentDown.class) .withCommand(EnvironmentList.class); cli .withGroup("test") .withDefaultCommand(Help.class) // TODO should be group aware https://github.com/airlift/airline/issues/72? Otherwise it's required until https://github.com/airlift/airline/pull/71 .withCommand(TestRun.class); cli.build().parse(commandFactory, args).run(); }
Example 2
Source File: GenerateTest.java From openapi-generator with Apache License 2.0 | 6 votes |
@SuppressWarnings("SameParameterValue") private void setupAndRunTest(String specFlag, final String spec, String langFlag, final String lang, String outputDirFlag, final String outputDir, boolean configuratorFromFile, final String configFile, String... additionalParameters) { final String[] commonArgs = {"generate", langFlag, lang, outputDirFlag, outputDir, specFlag, spec}; String[] argsToUse = ArrayUtils.addAll(commonArgs, additionalParameters); Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("openapi-generator-cli") .withCommands(Generate.class); Generate generate = (Generate) builder.build().parse(argsToUse); generate.configurator = configurator; generate.generator = generator; try { generate.run(); } finally { verify(configurator).setInputSpec(spec); verify(configurator).setGeneratorName(lang); verify(configurator).setOutputDir(outputDir); } }
Example 3
Source File: SchCli.java From datacollector with Apache License 2.0 | 6 votes |
boolean doMain(String[] args) { Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("streamsets sch") .withDescription("StreamSets Data Collector CLI interface for Control Hub") .withDefaultCommand(Help.class) .withCommands( Help.class, RegisterCommand.class, UnregisterCommand.class ); try { builder.build().parse(args).run(); return true; } catch (Exception ex) { System.err.println(ex.getMessage()); return false; } }
Example 4
Source File: StreamsetsCredentialStoreCli.java From datacollector with Apache License 2.0 | 6 votes |
boolean doMain(String[] args) { Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("streamsets stagelib-cli streamsets-credentialstore") .withDescription("StreamSets Data Collector Streamsets Credential Store CLI") .withDefaultCommand(Help.class) .withCommands( Help.class, DefaultSshKeyInfoCommand.class ); try { builder.build().parse(args).run(); return true; } catch (Exception ex) { if(Arrays.asList(args).contains("--stack")) { ex.printStackTrace(System.err); } else { System.err.println(ex.getMessage()); } return false; } }
Example 5
Source File: JavaKeystoreCredentialStoreCli.java From datacollector with Apache License 2.0 | 6 votes |
boolean doMain(String[] args) { Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("streamsets stagelib-cli jks-credentialstore") .withDescription("StreamSets Data Collector Java Keystore Credential Store CLI") .withDefaultCommand(Help.class) .withCommands( Help.class, ListCredentialsCommand.class, AddCredentialCommand.class, DeleteCredentialCommand.class ); try { builder.build().parse(args).run(); return true; } catch (Exception ex) { if(Arrays.asList(args).contains("--stack")) { ex.printStackTrace(System.err); } else { System.err.println(ex.getMessage()); } return false; } }
Example 6
Source File: MetadataGeneratorMain.java From datacollector with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public static void main(String[] args) { System.setProperty("sdc.conf.dir", System.getProperty("user.dir")); Configuration.setFileRefsBaseDir(new File(System.getProperty("user.dir"))); Cli.CliBuilder<Runnable> cliBuilder = Cli. <Runnable>builder("streamsets metadata-generator") .withDescription("Generates pipeline executor and stage libraries metadata for StreamSets Cloud") .withDefaultCommand(Help.class) .withCommands( Help.class, ExecutorMetadataCommand.class, StageLibMetadataCommand.class ); Runnable runnable = cliBuilder.build().parse(args); runnable.run(); }
Example 7
Source File: StageLibCli.java From datacollector with Apache License 2.0 | 6 votes |
boolean doMain(String[] args) { Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("streamsets stagelib-cli vault-credentialstore") .withDescription("StreamSets Data Collector Vault Credential Store CLI") .withDefaultCommand(Help.class) .withCommands(Help.class, VaultShowIdCommand.class); try { builder.build().parse(args).run(); return true; } catch (Exception ex) { if(Arrays.asList(args).contains("--stack")) { ex.printStackTrace(System.err); } else { System.err.println(ex.getMessage()); } return false; } }
Example 8
Source File: ToolkitMain.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static void main(String[] args) { initialProjectVersion(); String scriptName = System.getProperty("script.name"); Cli.CliBuilder<Runnable> builder = null; if (StringUtils.isNotEmpty(scriptName)) { builder = Cli.builder(scriptName); } else { builder = Cli.builder("java -jar cli-" + projectVersion + ".jar"); } builder.withDescription("Microservice development toolkit(version " + projectVersion + "). "); builder.withDefaultCommand(Help.class); builder.withCommands( CodeGenerate.class, DocGenerate.class, CheckStyle.class, CheckStyleAbbr.class, CheckCompatibility.class, CheckCompatibilityAbbr.class, Help.class ); try { Runnable cmd = builder.build().parse(args); cmd.run(); } catch (ValidationFailedException ex) { ex.printStackTrace(System.err); System.exit(1); } }
Example 9
Source File: SwaggerCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
public static void main(String[] args) { String version = Version.readVersionFromResources(); @SuppressWarnings("unchecked") Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("swagger-codegen-cli") .withDescription( String.format( "Swagger code generator CLI (version %s). More info on swagger.io", version)) .withDefaultCommand(Langs.class) .withCommands(Generate.class, Meta.class, Langs.class, Help.class, ConfigHelp.class, Validate.class, Version.class); builder.build().parse(args).run(); }
Example 10
Source File: AuthorTemplateTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Test public void smokeTestAuthorTemplateCommand(){ Cli.CliBuilder<Runnable> builder = createBuilder(); String[] arguments = new String[]{ "author", "template", "-g", "java", "--library", "webclient", "--output", outputDirectory.toAbsolutePath().toString() }; builder.build().parse(arguments).run(); // spot check root files Assert.assertTrue(Files.exists(outputDirectory.resolve("ApiClient.mustache"))); Assert.assertTrue(Files.exists(outputDirectory.resolve("api_doc.mustache"))); Assert.assertTrue(Files.exists(outputDirectory.resolve("pom.mustache"))); Assert.assertTrue(Files.exists(outputDirectory.resolve("auth/OAuth.mustache"))); // check libraries files and subdirectories Assert.assertTrue(Files.exists(outputDirectory.resolve("libraries/webclient/ApiClient.mustache"))); Assert.assertTrue(Files.exists(outputDirectory.resolve("libraries/webclient/pom.mustache"))); Assert.assertTrue(Files.exists(outputDirectory.resolve("libraries/webclient/auth/OAuth.mustache"))); // check non-existence of unselected libraries Assert.assertFalse(Files.exists(outputDirectory.resolve("libraries/feign/build.gradle.mustache"))); Assert.assertFalse(Files.exists(outputDirectory.resolve("libraries/feign/auth/OAuth.mustache"))); Assert.assertFalse(Files.exists(outputDirectory.resolve("libraries/jersey2/api_doc.mustache"))); Assert.assertFalse(Files.exists(outputDirectory.resolve("libraries/jersey2/auth/HttpBasicAuth.mustache"))); Assert.assertFalse(Files.exists(outputDirectory.resolve("libraries/okhttp-gson/api.mustache"))); Assert.assertFalse(Files.exists(outputDirectory.resolve("libraries/okhttp-gson/auth/RetryingOAuth.mustache"))); }
Example 11
Source File: AuthorTemplateTest.java From openapi-generator with Apache License 2.0 | 5 votes |
private Cli.CliBuilder<Runnable> createBuilder(){ Cli.CliBuilder<Runnable> builder = new Cli.CliBuilder<>("openapi-generator-cli"); builder.withGroup("author") .withDescription("Utilities for authoring generators or customizing templates.") .withDefaultCommand(HelpCommand.class) .withCommands(AuthorTemplate.class); return builder; }
Example 12
Source File: AlfrescoCLI.java From alfresco-client-sdk with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Cli.CliBuilder<Runnable> builder = Cli.<Runnable> builder("alfclient") .withDescription("Sample Alfresco Command Line Client").withDefaultCommand(Help.class) .withCommands(Help.class, AlfrescoCommands.infoUser.class) .withCommands(Help.class, AlfrescoCommands.listRoot.class); Cli<Runnable> gitParser = builder.build(); gitParser.parse(args).run(); }
Example 13
Source File: DataCollector.java From datacollector with Apache License 2.0 | 4 votes |
public static void main(String[] args) { Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("cli") .withDescription("StreamSets Data Collector CLI") .withDefaultCommand(Help.class) .withCommands( Help.class, PingCommand.class ); builder.withGroup("definitions") .withDescription("Returns Pipeline & Stage Configuration definitions") .withDefaultCommand(DefinitionsCommand.class) .withCommands(DefinitionsCommand.class); builder.withGroup("store") .withDescription("Store Commands") .withDefaultCommand(ListPipelinesCommand.class) .withCommands( ListPipelinesCommand.class, ExportPipelineCommand.class, ImportPipelineCommand.class, CreatePipelineCommand.class, GetPipelineConfigCommand.class, GetPipelineRulesCommand.class, DeletePipelineCommand.class, UpdatePipelineConfigCommand.class, UpdatePipelineRulesCommand.class, DeletePipelinesByFilteringCommand.class ); builder.withGroup("manager") .withDescription("Manager Commands") .withDefaultCommand(PipelineStatusCommand.class) .withCommands( PipelineStatusCommand.class, PipelineMetricsCommand.class, StartPipelineCommand.class, StopPipelineCommand.class, AlertsCommand.class, DeleteAlertCommand.class, SampledRecordsCommand.class, ResetOriginCommand.class, ErrorRecordsCommand.class, ErrorMessagesCommand.class, SnapshotListCommand.class, SnapshotCaptureCommand.class, SnapshotStatusCommand.class, SnapshotDataCommand.class, SnapshotDeleteCommand.class, PipelineHistoryCommand.class, DeletePipelineHistoryCommand.class, GetCommittedOffsetsCommand.class, UpdateCommittedOffsetsCommand.class ); builder.withGroup("system") .withDescription("System Commands") .withDefaultCommand(InfoCommand.class) .withCommands( ConfigurationCommand.class, DirectoriesCommand.class, InfoCommand.class, CurrentUserCommand.class, ServerTimeCommand.class, ShutdownCommand.class, ThreadsCommand.class, EnableDPMCommand.class, DisableDPMCommand.class ); builder.withGroup("preview") .withDescription("Preview Commands") .withDefaultCommand(RunPreviewCommand.class) .withCommands( RunPreviewCommand.class, PreviewStatusCommand.class, PreviewDataCommand.class, StopPreviewCommand.class, ValidatePipelineCommand.class ); try { builder.build().parse(args).run(); } catch (ParseOptionMissingException | ParseArgumentsUnexpectedException ex) { if(Arrays.asList(args).contains("--stack")) { ex.printStackTrace(); } else { System.out.println(ex.getMessage()); } } }
Example 14
Source File: CliCommandCreator.java From druid-api with Apache License 2.0 | votes |
public void addCommands(Cli.CliBuilder builder);