use of org.apache.commons.cli.Option in project eiger by wlloyd.
the class Stress method printHelpMessage.
/**
* Printing out help message
*/
public static void printHelpMessage() {
System.out.println("Usage: ./bin/stress [options]\n\nOptions:");
for (Object o : Session.availableOptions.getOptions()) {
Option option = (Option) o;
String upperCaseName = option.getLongOpt().toUpperCase();
System.out.println(String.format("-%s%s, --%s%s%n\t\t%s%n", option.getOpt(), (option.hasArg()) ? " " + upperCaseName : "", option.getLongOpt(), (option.hasArg()) ? "=" + upperCaseName : "", option.getDescription()));
}
}
use of org.apache.commons.cli.Option 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.Option in project streamsx.health by IBMStreams.
the class VinesAdapterService method main.
public static void main(String[] args) throws Exception {
Option contextOption = Option.builder("c").longOpt("context-type").hasArg().argName("context type").required().build();
Option hostOption = Option.builder("h").longOpt("host").hasArg().argName("host").required().build();
Option portOption = Option.builder("p").longOpt("port").hasArg().argName("port").required().build();
Option usernameOption = Option.builder("u").longOpt("username").hasArg().argName("username").required().build();
Option passwordOption = Option.builder("P").longOpt("password").hasArg().argName("password").required().build();
Option queueOption = Option.builder("q").longOpt("queue").hasArg().argName("queue").required().build();
Option exchangeOption = Option.builder("e").longOpt("exchange").hasArg().argName("exchange name").required().build();
Option debugOption = Option.builder("d").longOpt("debug").hasArg().argName("isDebugEnabled").required(false).type(Boolean.class).build();
Option mappingEnabledOption = Option.builder("m").longOpt("mappingEnabled").hasArg().argName("isMappingEnabled").required().build();
Options options = new Options();
options.addOption(contextOption);
options.addOption(hostOption);
options.addOption(portOption);
options.addOption(usernameOption);
options.addOption(passwordOption);
options.addOption(queueOption);
options.addOption(exchangeOption);
options.addOption(debugOption);
options.addOption(mappingEnabledOption);
CommandLineParser parser = new DefaultParser();
CommandLine cmd = null;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("help", options);
throw (e);
}
boolean isDebug = Boolean.valueOf(cmd.getOptionValue("d", Boolean.FALSE.toString()));
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("hostAndPort", cmd.getOptionValue("h") + ":" + cmd.getOptionValue("p"));
params.put("username", cmd.getOptionValue("u"));
params.put("password", cmd.getOptionValue("P"));
params.put("queueName", cmd.getOptionValue("q"));
params.put("exchangeName", cmd.getOptionValue("e", ""));
params.put("mappingEnabled", cmd.getOptionValue("m"));
HashMap<String, Object> config = new HashMap<>();
config.put(ContextProperties.SUBMISSION_PARAMS, params);
if (isDebug) {
config.put(ContextProperties.TRACING_LEVEL, TraceLevel.TRACE);
}
VinesAdapterService svc = new VinesAdapterService();
svc.run(Type.valueOf(cmd.getOptionValue("c", "DISTRIBUTED")), config);
if (isDebug) {
// launch a debug service to print raw messages to the console
Topology rawMsgTopo = new Topology("VinesRawMsgDebug");
rawMsgTopo.subscribe(VinesAdapterService.VINES_DEBUG_TOPIC, String.class).print();
StreamsContextFactory.getStreamsContext(Type.DISTRIBUTED).submit(rawMsgTopo).get();
// launch a debug service to print Observation tuples to the console
Topology obsTopo = new Topology("VinesObservationDebug");
SubscribeConnector.subscribe(obsTopo, VinesAdapterService.VINES_TOPIC).print();
StreamsContextFactory.getStreamsContext(Type.DISTRIBUTED).submit(obsTopo).get();
// launch a debug service to print errors to the console
Topology errTopo = new Topology("VinesErrorDebug");
errTopo.subscribe(VinesAdapterService.VINES_ERROR_TOPIC, String.class).print();
StreamsContextFactory.getStreamsContext(Type.DISTRIBUTED).submit(errTopo).get();
}
}
use of org.apache.commons.cli.Option in project streamsx.health by IBMStreams.
the class PrintService method main.
public static void main(String[] args) throws Exception {
Option subscribeTopicOption = Option.builder("s").longOpt("subscribe-topic").hasArg().argName("subscribe topic").required().build();
Option contextTypeOption = Option.builder("c").longOpt("context-type").hasArg().argName("context type").required(false).build();
Options options = new Options();
options.addOption(subscribeTopicOption);
options.addOption(contextTypeOption);
CommandLineParser parser = new DefaultParser();
CommandLine cmd = null;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("help", options);
throw (e);
}
Type contextType = Type.valueOf(cmd.getOptionValue("c", Type.DISTRIBUTED.name()));
String subscribeTopic = cmd.getOptionValue("s");
PrintService svc = new PrintService(subscribeTopic);
svc.run(contextType, new HashMap<String, Object>());
}
use of org.apache.commons.cli.Option in project streamsx.health by IBMStreams.
the class AbstractEventService method launchService.
protected static void launchService(String[] args, Class<? extends AbstractEventService> eventServiceClass) throws Exception {
Option hostOption = Option.builder("x").longOpt("host").hasArg().argName("watson explorer host").required().build();
Option portOption = Option.builder("p").longOpt("port").hasArg().argName("watson explorer port").required().build();
Option collectionOption = Option.builder("c").longOpt("collection").hasArg().argName("collection name").required().build();
Option patientIdFieldOption = Option.builder("f").longOpt("patient-field").hasArg().argName("patient ID field name").required(false).build();
Option toolkitOption = Option.builder("t").longOpt("toolkit-path").hasArg().argName("watson explorer toolkit path").required().build();
Option subscribeOption = Option.builder("s").longOpt("subscription-topic").hasArg().argName("subscription topic").required().build();
Option debugOption = Option.builder("d").longOpt("debug").hasArg().argName("isDebugEnabled").required(false).type(Boolean.class).build();
Options options = new Options();
options.addOption(hostOption);
options.addOption(portOption);
options.addOption(collectionOption);
options.addOption(patientIdFieldOption);
options.addOption(toolkitOption);
options.addOption(subscribeOption);
options.addOption(debugOption);
CommandLineParser parser = new DefaultParser();
CommandLine cmd = null;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("help", options);
throw (e);
}
boolean isDebug = cmd.getOptionValue("d", "false").equals("true");
AbstractEventService svc = eventServiceClass.getConstructor(String.class).newInstance(cmd.getOptionValue("t"));
//MedicationEventService svc = new MedicationEventService(cmd.getOptionValue("t"));
svc.setContextType(Type.DISTRIBUTED);
svc.addSubmissionTimeParam("wex.host", cmd.getOptionValue("x"));
svc.addSubmissionTimeParam("wex.port", Integer.valueOf(cmd.getOptionValue("p")));
svc.addSubmissionTimeParam("wex.patient.field.name", cmd.getOptionValue("f", "patient_id"));
svc.addSubmissionTimeParam("collectionName", cmd.getOptionValue("c"));
svc.setSubscriptionTopic(cmd.getOptionValue("s"));
if (isDebug) {
svc.setTraceLevel(TraceLevel.TRACE);
}
svc.buildAndRun();
if (isDebug) {
new EventBeacon(svc.getPublishedTopic()).run();
}
}
Aggregations