List of usage examples for org.apache.commons.cli OptionBuilder withArgName
public static OptionBuilder withArgName(String name)
From source file:find.Main.java
private static Options getOptions() { Option dir = OptionBuilder.withArgName("dir").hasArg().withDescription("list files in given dir") .create("dir"); Option name = OptionBuilder.withArgName("name").hasArg().withDescription("list files with given name") .create("name"); Options options = new Options(); options.addOption(dir);/* w w w . ja v a2s .c o m*/ options.addOption(name); return options; }
From source file:com.chip8java.emulator.Runner.java
/** * Generates the set of options for the command line option parser. * /* w w w . j a v a2s . c o m*/ * @return The options for the emulator */ public static Options generateOptions() { Options options = new Options(); @SuppressWarnings("static-access") Option delay = OptionBuilder.withArgName("delay").hasArg() .withDescription("sets the CPU operation to take at least " + "the specified number of milliseconds to execute " + "(default is " + CentralProcessingUnit.DEFAULT_CPU_CYCLE_TIME + ")") .create(DELAY_OPTION); @SuppressWarnings("static-access") Option scale = OptionBuilder.withArgName("scale").hasArg() .withDescription("the scale factor to apply to the display " + "(default is " + SCALE_DEFAULT + ")") .create(SCALE_OPTION); @SuppressWarnings("static-access") Option trace = OptionBuilder.withDescription("starts the CPU in trace mode").create(TRACE_OPTION); @SuppressWarnings("static-access") Option help = OptionBuilder.withDescription("show this help message and exit").create(HELP_OPTION); options.addOption(help); options.addOption(delay); options.addOption(scale); options.addOption(trace); return options; }
From source file:com.comcast.oscar.cli.commands.DownstreamFrequency.java
/** * Set option parameters for command Downstream Frequency * @return Option/*from ww w .ja v a 2 s . c om*/ */ public static final Option OptionParameters() { OptionBuilder.withArgName("downstream frequency"); OptionBuilder.hasArgs(1); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("dsfreq"); OptionBuilder.withDescription("Insert this downstream frequency during file compilation EX: 723000000."); return OptionBuilder.create("df"); }
From source file:com.comcast.oscar.cli.commands.Output.java
/** * Set option parameters for command Output * @return Option// w w w . j a v a 2 s . c om */ public static final Option OptionParameters() { OptionBuilder.withArgName("filename"); OptionBuilder.hasArgs(1); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("output"); OptionBuilder.withDescription("Compile the input file to this output file."); return OptionBuilder.create("o"); }
From source file:com.example.geomesa.kafka.KafkaListener.java
public static Options getCommonRequiredOptions() { Options options = new Options(); Option kafkaBrokers = OptionBuilder.withArgName("brokers").hasArg().isRequired() .withDescription("The comma-separated list of Kafka brokers, e.g. localhost:9092") .create("brokers"); options.addOption(kafkaBrokers);// w w w .j a v a2 s . c o m Option zookeepers = OptionBuilder.withArgName("zookeepers").hasArg().isRequired().withDescription( "The comma-separated list of Zookeeper nodes that support your Kafka instance, e.g.: zoo1:2181,zoo2:2181,zoo3:2181") .create("zookeepers"); options.addOption(zookeepers); Option zkPath = OptionBuilder.withArgName("zkPath").hasArg() .withDescription("Zookeeper's discoverable path for metadata, defaults to /geomesa/ds/kafka") .create("zkPath"); options.addOption(zkPath); return options; }
From source file:carmen.utils.CommandLineUtilities.java
/** * This uses the apache Jakarta CLI to parse the command line. * A single static instance of this class exists for global access by all parts * of the program./*w w w. j a v a2s.c o m*/ * To use this class, a list of options must be specified and passed to this method. * Manditory arguments should be encoded as strings. * @param args The command line received by main * @param manditory_args A list of strings that contain the names of manditory arguments. * @param specified_options A list of options to use for this program. */ public static void initCommandLineParameters(String[] args, List<Option> specified_options, String[] manditory_args) { Options options = new Options(); if (specified_options != null) for (Option option : specified_options) options.addOption(option); Option option = null; OptionBuilder.withArgName("file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("A file containing command line parameters as a Java properties file."); option = OptionBuilder.create("parameter_file"); options.addOption(option); CommandLineParser command_line_parser = new GnuParser(); CommandLineUtilities._properties = new Properties(); try { CommandLineUtilities._command_line = command_line_parser.parse(options, args); } catch (ParseException e) { System.out.println("***ERROR: " + e.getClass() + ": " + e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("parameters:", options); System.exit(0); } if (CommandLineUtilities.hasArg("parameter_file")) { String parameter_file = CommandLineUtilities.getOptionValue("parameter_file"); // Read the property file. try { _properties.load(new FileInputStream(parameter_file)); } catch (IOException e) { System.err.println("Problem reading parameter file: " + parameter_file); } } boolean failed = false; if (manditory_args != null) { for (String arg : manditory_args) { if (!CommandLineUtilities.hasArg(arg)) { failed = true; System.out.println("Missing argument: " + arg); } } if (failed) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("parameters:", options); System.exit(0); } } }
From source file:com.comcast.oscar.cli.commands.TLVDescription.java
/** * Set option parameters for command TLV description * @return Option//from www. j a v a 2 s. com */ public static final Option OptionParameters() { OptionBuilder.withArgName("TLV dot notation"); OptionBuilder.hasArgs(1); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("tlvdescription"); OptionBuilder.withDescription("Display the TLV description (EX: 26.1)."); return OptionBuilder.create("td"); }
From source file:com.flaptor.indextank.rpc.SearcherClient.java
@SuppressWarnings("static-access") private static Options getOptions() { Option hostName = OptionBuilder.withArgName("server-host").hasArg() .withDescription("the host where the server is running").withLongOpt("host").create("h"); Option basePort = OptionBuilder.withArgName("base-port").hasArg() .withDescription("The base port where the server is running").withLongOpt("port").create("p"); Option function = OptionBuilder.withArgName("scoring-function").hasArg() .withDescription("The scoring function index").withLongOpt("function").create("f"); Option help = OptionBuilder.withDescription("displays this help").withLongOpt("help").create("help"); Options options = new Options(); options.addOption(hostName);//from w ww. ja v a2 s . c o m options.addOption(basePort); options.addOption(function); options.addOption(help); return options; }
From source file:com.comcast.oscar.cli.commands.TLVtoJSON.java
/** * Set option parameters for command TLV to JSON display * @return Option// w ww . j a va 2 s .co m */ public static final Option OptionParameters() { OptionBuilder.withArgName("TLV"); OptionBuilder.hasArgs(); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("tlv2json"); OptionBuilder.withDescription( "View the JSON array of a TLV EX: 030101 (NetworkAccess: Type 3 Length 1 Value 1)."); return OptionBuilder.create("t2j"); }
From source file:com.comcast.oscar.cli.commands.Input.java
/** * Set option parameters for command Input * @return Option/* w w w. j ava 2s.co m*/ */ public static final Option OptionParameters() { OptionBuilder.withArgName("filename"); OptionBuilder.hasArgs(1); OptionBuilder.hasOptionalArgs(); OptionBuilder.withValueSeparator(' '); OptionBuilder.withLongOpt("input"); OptionBuilder.withDescription("File to analyze and/or compile/decompile."); return OptionBuilder.create("i"); }