List of usage examples for org.apache.commons.cli Option Option
public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException
From source file:com.ericsson.eiffel.remrem.generate.cli.CLIOptions.java
/** * Creates the options needed by command line interface * /*from ww w . j a v a 2 s.com*/ * @return the options this CLI can handle */ public static Options createCLIOptions() { options = new Options(); typeGroup = new OptionGroup(); Option msgTypeOpt = new Option("t", "message_type", true, "message type"); typeGroup.addOption(msgTypeOpt); options.addOptionGroup(typeGroup); options.addOption("h", "help", false, "show help."); options.addOption("r", "response_file", true, "file to store the response in, optional"); options.addOption("d", "debug", false, "enable debug traces"); options.addOption("mp", "messaging_protocol", true, "name of messaging protocol to be used, e.g. eiffel3, eiffelsemantics"); contentGroup = new OptionGroup(); contentGroup.addOption(new Option("f", "content_file", true, "message content file")); contentGroup.addOption(new Option("json", "json_content", true, "json content")); options.addOptionGroup(contentGroup); options.addOption("v", "list_versions", false, "lists the versions of generate and all loaded protocols"); return options; }
From source file:com.medvision360.medrecord.tools.dumpadl.CommandLineReader.java
/** * Constructor.// ww w . j a v a2 s . c o m * <p/> * Creates the commandline options. */ public CommandLineReader() { super(); m_options = new Options(); final Option adlOption = new Option("i", "adl", true, "The ADL file to parse."); adlOption.setRequired(true); adlOption.setArgName("adl-file"); m_options.addOption(adlOption); }
From source file:com.amazonaws.services.dynamodbv2.online.index.ViolationDetector.java
public static void main(String[] args) { CommandLine commandLine;//from ww w . j av a 2s. co m org.apache.commons.cli.Options options = new org.apache.commons.cli.Options(); CommandLineParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); Option optionHelp = new Option("h", "help", false, "Help and usage information"); OptionBuilder.withArgName("keep/delete"); OptionBuilder.withLongOpt("detect"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Detect violations on given table. " + "\nwith 'keep', violations will be kept and recorded;" + "\nwith 'delete', violations will be deleted and recorded."); Option optionDetection = OptionBuilder.create("t"); OptionBuilder.withArgName("update/delete"); OptionBuilder.withLongOpt("correct"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Correct violations based on records on correction input file." + "\nwith 'delete', records on input file will be deleted from the table;" + "\nwith 'update', records on input file will be updated to the table."); Option optionCorrection = OptionBuilder.create("c"); OptionBuilder.withArgName("configFilePath"); OptionBuilder.withLongOpt("configFilePath"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "Path of the config file. \nThis option is required for both detection and correction."); Option optionConfigFilePath = OptionBuilder.create("p"); options.addOption(optionConfigFilePath); options.addOption(optionDetection); options.addOption(optionCorrection); options.addOption(optionHelp); try { ViolationDetector detector = new ViolationDetector(); commandLine = parser.parse(options, args); /** Violation detection */ if (commandLine.hasOption("t")) { if (!commandLine.hasOption("p")) { logger.error("Config file path not provided. Exiting..."); formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); System.exit(1); } String configFilePath = commandLine.getOptionValue("p"); detector.setConfigFile(configFilePath); String detectOption = commandLine.getOptionValue("t"); if (detectOption.compareTo("delete") == 0) { confirmDelete(); detector.initDetection(); detector.violationDetection(true); } else if (detectOption.compareTo("keep") == 0) { detector.initDetection(); detector.violationDetection(false); } else { String errMessage = "Invalid options " + detectOption + " for 't/detect'"; logger.error(errMessage + ". Exiting..."); formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); System.exit(1); } return; } /** Violation correction */ if (commandLine.hasOption("c")) { if (!commandLine.hasOption("p")) { logger.error("Config file path not provided. Exiting..."); formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); System.exit(1); } String configFilePath = commandLine.getOptionValue("p"); detector.setConfigFile(configFilePath); String correctOption = commandLine.getOptionValue("c"); if (correctOption.compareTo("delete") == 0) { confirmDelete(); detector.initCorrection(); detector.violationCorrection(true, false /* useConditionalUpdate */); } else if (correctOption.compareTo("update") == 0) { detector.initCorrection(); boolean useConditionalUpdate = getUseConditionalUpdateOptionFromConsole(); detector.violationCorrection(false, useConditionalUpdate); } else { String errMessage = "Invalid options " + correctOption + " for 'c/correct'"; logger.error(errMessage + ". Exiting..."); formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); System.exit(1); } return; } /** Help information */ if (commandLine.hasOption("h")) { formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); return; } /** Error: print usage and exit */ String errMessage = "Invalid options, check usage"; logger.error(errMessage + ". Exiting..."); formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); System.exit(1); } catch (IllegalArgumentException iae) { logger.error("Exception!", iae); System.exit(1); } catch (ParseException e) { logger.error("Exception!", e); formatter.printHelp(TOOL_USAGE_WIDTH, TOOL_USAGE, null /*header*/, options, null /*footer*/); System.exit(1); } }
From source file:com.aliyun.openservices.odps.console.resource.DropFunctionCommand.java
static Options initOptions() { Options opts = new Options(); Option project_name = new Option("p", "project", true, "project name"); project_name.setRequired(false);//from w ww . jav a 2 s . c o m opts.addOption(project_name); return opts; }
From source file:com.garethahealy.fuse.aries.transactions.cli.parsers.DefaultCLIParser.java
public Options getOptions() { //Setup the options we can use on the command line Option dbDriverOption = new Option("db", "database", true, "Comma-seperated database options, i.e.: option=value,option=value"); Options options = new Options(); options.addOption(dbDriverOption);/*from w w w .j a va 2 s . co m*/ return options; }
From source file:com.alibaba.rocketmq.broker.BrokerStartup.java
public static Options buildCommandlineOptions(final Options options) { Option opt = new Option("c", "configFile", true, "Broker config properties file"); opt.setRequired(false);//from w w w . j a v a2 s . c om options.addOption(opt); opt = new Option("p", "printConfigItem", false, "Print all config item"); opt.setRequired(false); options.addOption(opt); opt = new Option("m", "printImportantConfig", false, "Print important config item"); opt.setRequired(false); options.addOption(opt); return options; }
From source file:com.alibaba.rocketmq.tools.command.namesrv.DeleteKvConfigCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("s", "namespace", true, "set the namespace"); opt.setRequired(true);/*www .ja v a 2 s .c om*/ options.addOption(opt); opt = new Option("k", "key", true, "set the key name"); opt.setRequired(true); options.addOption(opt); return options; }
From source file:edu.cmu.tetrad.cli.CausalCmdApplication.java
private static void populateMainOptions() { OptionGroup optGrp = new OptionGroup(); optGrp.addOption(new Option(null, ALGO_OPT, true, algorithmCmd())); optGrp.addOption(new Option(null, SIM_DATA_OPT, true, simulationCmd())); optGrp.setRequired(true);/*from w w w . j a v a 2s . c o m*/ MAIN_OPTIONS.addOptionGroup(optGrp); MAIN_OPTIONS.addOption(null, VERSION_OPT, false, "Version."); }
From source file:com.alibaba.rocketmq.tools.command.namesrv.UpdateKvConfigCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("s", "namespace", true, "set the namespace"); opt.setRequired(true);/*from ww w .java2 s.c om*/ options.addOption(opt); opt = new Option("k", "key", true, "set the key name"); opt.setRequired(true); options.addOption(opt); opt = new Option("v", "value", true, "set the key value"); opt.setRequired(true); options.addOption(opt); return options; }
From source file:com.alibaba.rocketmq.tools.command.topic.TopicRouteSubCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("t", "topic", true, "topic name"); opt.setRequired(true);//w ww . java2 s .c om options.addOption(opt); return options; }