use of com.google.api.codegen.discogapic.DiscoGapicGeneratorApp in project toolkit by googleapis.
the class GeneratorMain method discoGapicMain.
public static void discoGapicMain(ArtifactType artifactType, String[] args) throws Exception {
Options options = new Options();
options.addOption("h", "help", false, "show usage");
// TODO make required after artman passes this in
options.addOption(LANGUAGE_NONREQUIRED_OPTION);
options.addOption(DISCOVERY_DOC_OPTION);
// TODO (andrealin): Make Gapic YAML optional
options.addOption(GAPIC_YAML_OPTION);
options.addOption(PACKAGE_YAML2_OPTION);
options.addOption(OUTPUT_OPTION);
Option enabledArtifactsOption = Option.builder().longOpt("enabled_artifacts").desc("Optional. Artifacts enabled for the generator. " + "Currently supports 'surface' and 'test'.").hasArg().argName("ENABLED_ARTIFACTS").required(false).build();
options.addOption(enabledArtifactsOption);
CommandLine cl = (new DefaultParser()).parse(options, args);
if (cl.hasOption("help")) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("DiscoGapicGeneratorTool", options);
}
ToolOptions toolOptions = ToolOptions.create();
toolOptions.set(DiscoGapicGeneratorApp.LANGUAGE, cl.getOptionValue(LANGUAGE_NONREQUIRED_OPTION.getLongOpt()));
toolOptions.set(DiscoGapicGeneratorApp.DISCOVERY_DOC, cl.getOptionValue(DISCOVERY_DOC_OPTION.getLongOpt()));
toolOptions.set(GapicGeneratorApp.OUTPUT_FILE, cl.getOptionValue(OUTPUT_OPTION.getLongOpt(), ""));
toolOptions.set(GapicGeneratorApp.GENERATOR_CONFIG_FILES, Lists.newArrayList(cl.getOptionValues(GAPIC_YAML_OPTION.getLongOpt())));
toolOptions.set(GapicGeneratorApp.PACKAGE_CONFIG2_FILE, cl.getOptionValue(PACKAGE_YAML2_OPTION.getLongOpt()));
if (cl.getOptionValues(enabledArtifactsOption.getLongOpt()) != null) {
toolOptions.set(GapicGeneratorApp.ENABLED_ARTIFACTS, Lists.newArrayList(cl.getOptionValues(enabledArtifactsOption.getLongOpt())));
}
DiscoGapicGeneratorApp codeGen = new DiscoGapicGeneratorApp(toolOptions, artifactType);
int exitCode = codeGen.run();
System.exit(exitCode);
}
Aggregations