use of org.apache.commons.cli.DefaultParser in project toolkit by googleapis.
the class DiscoConfigGeneratorTool method main.
public static void main(String[] args) throws Exception {
Options options = new Options();
options.addOption("h", "help", false, "show usage");
options.addOption(Option.builder().longOpt(DISCOVERY_DOC_OPTION_NAME).desc("The filepath of the raw Discovery document.").hasArg().argName("DISCOVERY-FILE").required(true).build());
options.addOption(Option.builder("o").longOpt("output").desc("The directory in which to output the generated config.").hasArg().argName("OUTPUT-FILE").required(true).build());
CommandLine cl = (new DefaultParser()).parse(options, args);
if (cl.hasOption("help")) {
HelpFormatter formater = new HelpFormatter();
formater.printHelp("ConfigGeneratorTool", options);
}
generate(cl.getOptionValue(DISCOVERY_DOC_OPTION_NAME), cl.getOptionValue("output"));
}
use of org.apache.commons.cli.DefaultParser in project toolkit by googleapis.
the class SynchronizerTool method main.
public static void main(String[] args) throws Exception {
Options options = new Options();
options.addOption("h", "help", false, "show usage");
options.addOption(Option.builder().longOpt("source_path").desc("The directory which contains the final code.").hasArg().argName("SOURCE-PATH").required(true).build());
options.addOption(Option.builder().longOpt("generated_path").desc("The directory which contains the generated code.").hasArg().argName("GENERATED-PATH").build());
options.addOption(Option.builder().longOpt("baseline_path").desc("The directory which contains the baseline code.").hasArg().argName("BASELINE-PATH").build());
options.addOption(Option.builder().longOpt("auto_merge").desc("If set, no GUI will be launched if merge can be completed automatically.").argName("AUTO-MERGE").build());
options.addOption(Option.builder().longOpt("auto_resolve").desc("Whether to enable smart conflict resolution").argName("AUTO_RESOLVE").build());
options.addOption(Option.builder().longOpt("ignore_base").desc("If true, the baseline will be ignored and two-way merge will be used.").argName("IGNORE_BASE").build());
CommandLine cl = (new DefaultParser()).parse(options, args);
if (cl.hasOption("help")) {
HelpFormatter formater = new HelpFormatter();
formater.printHelp("CodeGeneratorTool", options);
}
synchronize(cl.getOptionValue("source_path"), cl.getOptionValue("generated_path"), cl.getOptionValue("baseline_path"), cl.hasOption("auto_merge"), cl.hasOption("auto_resolve"), cl.hasOption("ignore_base"));
}
use of org.apache.commons.cli.DefaultParser in project grakn by graknlabs.
the class MigrationOptions method parse.
protected void parse(String[] args) {
try {
CommandLineParser parser = new DefaultParser();
command = parser.parse(options, args);
numberOptions = command.getOptions().length;
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
use of org.apache.commons.cli.DefaultParser in project grakn by graknlabs.
the class GraqlShellOptions method create.
public static GraqlShellOptions create(String[] args, Options additionalOptions) throws ParseException {
Options options = defaultOptions();
for (Option option : additionalOptions.getOptions()) {
options.addOption(option);
}
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
return new GraqlShellOptions(options, cmd);
}
use of org.apache.commons.cli.DefaultParser in project scheduling by ow2-proactive.
the class RMNodeUpdater method parseCommandLine.
@Override
protected String parseCommandLine(String[] args) {
final Options options = new Options();
fillOptions(options);
final CommandLineParser parser = new DefaultParser();
CommandLine cl;
try {
cl = parser.parse(options, args);
// now we update this object's fields given the options.
String nodeName = fillParameters(cl, options);
// check the user supplied values
// performed after fillParameters to be able to override fillParameters in subclasses
checkUserSuppliedParameters();
return nodeName;
} catch (ParseException pe) {
logger.error("Error when parsing arguments", pe);
System.exit(ExitStatus.RMNODE_PARSE_ERROR.exitCode);
}
return null;
}
Aggregations