use of org.apache.commons.cli.Options in project heron by twitter.
the class SchedulerMain method main.
public static void main(String[] args) throws Exception {
// construct the options and help options first.
Options options = constructOptions();
Options helpOptions = constructHelpOptions();
// parse the options
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(helpOptions, args, true);
// print help, if we receive wrong set of arguments
if (cmd.hasOption("h")) {
usage(options);
return;
}
// Now parse the required options
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
usage(options);
throw new RuntimeException("Error parsing command line options: ", e);
}
// It returns a new empty Properties instead of null,
// if no properties passed from command line. So no need for null check.
Properties schedulerProperties = cmd.getOptionProperties(SchedulerUtils.SCHEDULER_COMMAND_LINE_PROPERTIES_OVERRIDE_OPTION);
// initialize the scheduler with the options
String topologyName = cmd.getOptionValue("topology_name");
SchedulerMain schedulerMain = createInstance(cmd.getOptionValue("cluster"), cmd.getOptionValue("role"), cmd.getOptionValue("environment"), cmd.getOptionValue("topology_bin"), topologyName, Integer.parseInt(cmd.getOptionValue("http_port")), cmd.hasOption("verbose"), schedulerProperties);
LOG.info("Scheduler command line properties override: " + schedulerProperties.toString());
// run the scheduler
boolean ret = schedulerMain.runScheduler();
// Log the result and exit
if (!ret) {
throw new RuntimeException("Failed to schedule topology: " + topologyName);
} else {
// stop the server and close the state manager
LOG.log(Level.INFO, "Shutting down topology: {0}", topologyName);
}
}
use of org.apache.commons.cli.Options in project heron by twitter.
the class MetricsCacheManager method constructHelpOptions.
// construct command line help options
private static Options constructHelpOptions() {
Options options = new Options();
Option help = Option.builder("h").desc("List all options and their description").longOpt("help").build();
options.addOption(help);
return options;
}
use of org.apache.commons.cli.Options in project heron by twitter.
the class CppCheckstyle method main.
public static void main(String[] args) throws IOException {
CommandLineParser parser = new DefaultParser();
// create the Options
Options options = new Options();
options.addOption(Option.builder("f").required(true).hasArg().longOpt("extra_action_file").desc("bazel extra action protobuf file").build());
options.addOption(Option.builder("c").required(true).hasArg().longOpt("cpplint_file").desc("Executable cpplint file to invoke").build());
try {
// parse the command line arguments
CommandLine line = parser.parse(options, args);
String extraActionFile = line.getOptionValue("f");
String cpplintFile = line.getOptionValue("c");
Collection<String> sourceFiles = getSourceFiles(extraActionFile);
if (sourceFiles.size() == 0) {
LOG.fine("No cpp files found by checkstyle");
return;
}
LOG.fine(sourceFiles.size() + " cpp files found by checkstyle");
// Create and run the command
List<String> commandBuilder = new ArrayList<>();
commandBuilder.add(cpplintFile);
commandBuilder.add("--linelength=100");
// TODO: https://github.com/twitter/heron/issues/466,
// Remove "runtime/references" when we fix all non-const references in our codebase.
// TODO: https://github.com/twitter/heron/issues/467,
// Remove "runtime/threadsafe_fn" when we fix all non-threadsafe libc functions
commandBuilder.add("--filter=-build/header_guard,-runtime/references,-runtime/threadsafe_fn");
commandBuilder.addAll(sourceFiles);
runLinter(commandBuilder);
} catch (ParseException exp) {
LOG.severe(String.format("Invalid input to %s: %s", CLASSNAME, exp.getMessage()));
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("java " + CLASSNAME, options);
}
}
use of org.apache.commons.cli.Options in project uPortal by Jasig.
the class PortalShell method getOptions.
protected static Options getOptions() {
final Options options = new Options();
options.addOption(new Option("s", "script", true, "Groovy script to execute in the uPortal Shell."));
return options;
}
use of org.apache.commons.cli.Options in project zm-mailbox by Zimbra.
the class FixCalendarPriorityUtil method setupCommandLineOptions.
protected void setupCommandLineOptions() {
super.setupCommandLineOptions();
Options options = getOptions();
Option accountOpt = new Option(O_ACCOUNT, "account", true, "account email addresses seperated by white space or \"all\" for all accounts");
accountOpt.setArgs(Option.UNLIMITED_VALUES);
options.addOption(accountOpt);
options.addOption(new Option(null, O_SYNC, false, "run synchronously; default is asynchronous"));
options.addOption(SoapCLI.OPT_AUTHTOKEN);
options.addOption(SoapCLI.OPT_AUTHTOKENFILE);
}
Aggregations